未找到入口点异常
我尝试在 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);
}
这是该函数的转储箱:
5 4 00001020 ?aaeonAPIOpen@@YAPAXK@Z
我将 dll 导入更改为 [DllImport("aonAPI.dll", EntryPoint="?aaeonAPIOpen")]
和 [DllImport("aonAPI.dll" , EntryPoint="_aaeonAPIOpen")]
但没有运气。
I'm trying to use a C++ unmanaged dll in a C# project and I'm getting an error when trying to call a function that says that entry point cannot be found.
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);
}
Here is the dumpbin for the function:
5 4 00001020 ?aaeonAPIOpen@@YAPAXK@Z
I changed the dll import to [DllImport("aonAPI.dll", EntryPoint="?aaeonAPIOpen")]
and [DllImport("aonAPI.dll", EntryPoint="_aaeonAPIOpen")]
and no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 undname.exe 实用程序,该符号可以分解为
Which 做出正确的声明:
Using the undname.exe utility, that symbol demangles to
Which makes the proper declaration:
看起来您尝试调用的函数被编译为 C++ 函数,因此其名称已被破坏。 PInvoke 不支持损坏的名称。您需要在函数定义周围添加外部“C”块以防止名称修改
It looks like the function you're trying to call is compiled as a C++ function and hence has it's name mangled. PInvoke does not support mangled name. You need to add an extern "C" block around the function definition to prevent name mangling