Quantcast
Channel: Javascript .NET
Viewing all articles
Browse latest Browse all 137

New Post: new JavascriptContext() - An attempt to divide by zero

$
0
0
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);
                context.Run(script);
                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;
            try
            {
                ptr = StringToIntPtr(patronimic);
                 //If write here "return Gender.MasculineGender", 
                 //the problems with the creation JavascriptContext does not arise
                return (Gender)decGetSex(ptr);
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
}
full code on github

Viewing all articles
Browse latest Browse all 137

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>