This project is read-only.

new JavascriptContext() - An attempt to divide by zero

Feb 28, 2014 at 7:58 AM
Hi all! Sorry for my english.

I have a problem with integration of libraries Padeg.dll (Library decline on cases of russian names) and Noesis.Javascript.dll. I can't understand why these libraries conflict.

Brief description of the problem:
Calling any method imported from Padeg.dll leads to the library Noesis.Javascript throws on the line object creation JavascriptContext with the message "An attempt to divide by zero" (in russian "Попытка деления на ноль"). (StackTrace: "в v8.Context.New(Persistent<v8::Context> , ExtensionConfiguration , Handle<v8::ObjectTemplate> , Handle<v8::Value> )\r\n в Noesis.Javascript.JavascriptContext..ctor()\r\n в JSModule.JSPlug.JSRun(String script, Object& result) в D:\Projects\Visual Studio Projects\activity_manager\ScriptModule\JScript.cs:строка 36")
But if change the order of execution, everything works fine - if I first create an object JavascriptContext from Noesis.Javascript, and then call a method from Padeg.dll.

Parts of the code:
public void JSRun(string script, out object result)
            //When creating JavascriptContext be an exception if called methods of Padeg.dll before 
            using (JavascriptContext context = new JavascriptContext())  
                context.SetParameter("result", null);
                result = context.GetParameter("result").ToString();
[DllImport("Padeg.dll", EntryPoint = "GetSex")]
private static extern Int32 decGetSex(IntPtr patronimic);

public static Gender GetGender(string patronimic)
            if(patronimic == null) throw new ArgumentNullException("patronimic");

            IntPtr ptr = IntPtr.Zero;
                ptr = StringToIntPtr(patronimic);
                 //If write here "return Gender.MasculineGender", 
                 //the problems with the creation JavascriptContext does not arise
                return (Gender)decGetSex(ptr);
full code on github
Mar 10, 2014 at 5:56 AM
If your 'script' is not setting 'result' then you are calling ToString() on null. However I cannot see how this would become divide by zero.

The only other way I have known DLLs to influence each other is by fiddling with the floating point signal handling register (wherever that is). This might change whether a divide by zero in JavaScript returns NaN or throws an exception.