我尝试使用 P/Invoke 将示例 .net 应用程序转换为 javascript JSIL .
C# 代码:
[DllImport("JSTestLib", EntryPoint = "Get42", CallingConvention = CallingConvention.Cdecl)]
public unsafe static extern int Get42();
生成的 JavaScript:
$.ExternalMethod({Static:true , Public:true }, "Get42",
JSIL.MethodSignature.Return($.Int32)
);
我应该在 JavaScript 中的哪里添加 Get42 方法的实现?我应该在 JSIL 中手动注册这个方法吗?
我现在只有一个错误:
The external method 'System.Int32 Get42()' of type 'Test.Program' has not been implemented.
最佳答案
只需使用 JSIL.ImplementExternals - 查看 JSIL.Core.js 的示例
关于javascript - JSIL 和 DllImport,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26937553/