Search code examples
javascriptc#pinvokejsil

JSIL and DllImport


I try to convert sample .net application with P/Invoke to javascript with JSIL.

C# code:

[DllImport("JSTestLib", EntryPoint = "Get42", CallingConvention = CallingConvention.Cdecl)]
public unsafe static extern int Get42();

Generated javascript:

$.ExternalMethod({Static:true , Public:true }, "Get42", 
  JSIL.MethodSignature.Return($.Int32)
);

Where should I add implementation of the Get42 method in javascript? Should I register this method manually in JSIL?

I have only an error now:

The external method 'System.Int32 Get42()' of type 'Test.Program' has not been implemented.


Solution

  • Just use JSIL.ImplementExternals - take a look at JSIL.Core.js for examples