简体   繁体   English

EntryPointNotFoundException外部JS库错误

[英]EntryPointNotFoundException external JS Lib error

Trying to implement JS library with my C# code. 试图用我的C#代码实现JS库。 Is very simple but I am getting this error: 很简单,但出现此错误:

EntryPointNotFoundException: Test TalkDB.Start () (at Assets/Scripts/TalkDB.cs:30) EntryPointNotFoundException:测试TalkDB.Start()(位于Assets / Scripts / TalkDB.cs:30)

C# code is in scripts folder and JS library at plugins/webgl with .jslib extension. C#代码位于scripts文件夹和JS /扩展名为.jslib的js库中。 Also read this article, but no idea what I am missing: https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html?_ga=1.27144893.1658401563.1487328483 还请阅读这篇文章,但不知道我缺少什么: https : //docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html?_ga=1.27144893.1658401563.1487328483

C# Code: C#代码:

public class TalkDB : MonoBehaviour
{
    [DllImport("__Internal")]
    private static extern void Test();

    void Start()
    {

        Test();

    }
}

JS Library: JS库:

var HighscorePlugin = {
    Test: function()
    {
        window.alert("Testing 1, 2, 3,...");
    }
};

mergeInto(LibraryManager.library, HighscorePlugin);

Found the answer, is quite simple in fact. 找到答案,其实很简单。 I does not work when running locally, just when running from a server. 在本地运行时,仅从服务器运行时,我不工作。 To prevent this error this should be done: 为防止此错误,应这样做:

#if UNITY_WEBGL && !UNITY_EDITOR #if UNITY_WEBGL &&!UNITY_EDITOR

[DllImport("__Internal")] private static extern void Test(); [DllImport(“ __ Internal”)]私有静态外部无效Test(); #else #其他

// something else to emulate what you want to do //其他模仿您想要做的事情

#endif #万一

And do this also when calling the function. 并在调用函数时也执行此操作。 Happy programming :) 快乐编程:)

EntryPointNotFoundExceptionmeans means that the function "Test" is either (A) not marked as exportable (not visible) or (B) signature does not match C# definition. EntryPointNotFoundExceptionmeans意味着函数(Test)是(A)未标记为可导出(不可见)或(B)签名与C#定义不匹配。

Most likely your issue is the former (A). 您的问题很可能是前者(A)。

I would recommend running DUMPBIN.EXE against your library to verify your "test" function is getting exported and that the its respective signature matches your C# definition. 我建议对您的库运行DUMPBIN.EXE以验证您的“测试”功能正在导出,并且其各自的签名与您的C#定义匹配。 Could be some code-injection on JS-side. 可能是在JS端进行了一些代码注入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM