![](/img/trans.png)
[英]Unable to find an entry point named xxx in mixed C++ DLL and WPF C# project
[英]Enable to call unmanaged method - "Unable to find an entry point named 'XXX' in DLL 'XXX.dll'."
我试图在 C# 控制台应用程序项目中使用 dll 中编写的 C 中的方法。 这是我得到的 h 文件中的方法签名:
DLL_PUBLIC sint AshrAPI_TranRecToRefunISO(char* TranRec , byte* RefunISO , usint* ISOLength);
我用P/Invoker在C#创建了对应的方法:
[DllImport(@"Ashrait.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
[return: MarshalAs(UnmanagedType.I2)]
internal static extern short AshrAPI_TranRecToRefunISO([MarshalAs(UnmanagedType.LPStr)] string TranRec, [MarshalAs(UnmanagedType.LPArray)] byte[] RefunISO, ushort ISOLength);
但无论我尝试使用哪种 UnmanagedType,我总是会遇到相同的异常:无法在 DLL 'XXX.dll 中找到名为 'XXX' 的入口点
任何人都可以看到错误吗?
所以发现了问题,因为我将 dll 加载为项目而不是参考。 我把它放在项目内的资源文件夹中:一旦我将 dll 移动到根项目文件夹,一切都开始工作了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.