繁体   English   中英

没有找到入口点的例外

[英]Entry Point Not Found Exception

我正在尝试在C#项目中使用C ++非托管dll,并且在尝试调用一个无法找到入口点的函数时遇到错误。

public class Program
{

    static void Main(string[] args)
    {
        IntPtr testIntPtr = aaeonAPIOpen(0);            
        Console.WriteLine(testIntPtr.ToString());
    }

    [DllImport("aonAPI.dll")]
    public static extern unsafe IntPtr aaeonAPIOpen(uint reserved);
}

这是函数的dumpbin:

5    4 00001020 ?aaeonAPIOpen@@YAPAXK@Z

我将dll导入更改为[DllImport("aonAPI.dll", EntryPoint="?aaeonAPIOpen")][DllImport("aonAPI.dll", EntryPoint="_aaeonAPIOpen")]并且没有运气。

使用undname.exe实用程序,该符号将解析为

 void * __cdecl aaeonAPIOpen(unsigned long)

这是正确的声明:

    [DllImport("aonAPI.dll", EntryPoint="?aaeonAPIOpen@@YAPAXK@Z", 
        ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
    public static extern IntPtr aaeonAPIOpen(uint reserved);

看起来你试图调用的函数被编译为C ++函数,因此它的名字被破坏了。 PInvoke不支持受损名称。 您需要在函数定义周围添加一个extern“C”块以防止名称损坏

extern "C" {
  void* aaeonAPIOpen(uint reserved);
}

暂无
暂无

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

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