没有找到入口点的例外
我正在尝试在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”块以防止名称损坏
上述就是C#学习教程:没有找到入口点的例外分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
extern "C" { void* aaeonAPIOpen(uint reserved); }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/987211.html