JSIL and DllImport

JSIL and DllImport

本文关键字:DllImport and JSIL      更新时间:2023-09-26

我尝试将带有P/Invoke的示例.net应用程序转换为使用JSIL的javascript。

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 中手动注册此方法吗?

我现在只有一个错误:

类型为"Test.Program"的外部方法"System.Int32 Get42()"具有 未实施。

只需使用 JSIL。ImplementExternals - 看看 JSIL。核心.js示例