我想在C#中加载C ++ dll(VS2012,也是在VS2012 C ++中创建的C ++ dll),在C ++中我已经使用了MATLAB生成的共享库并使用了deploytool。(我的配置都在C#中和C ++程序是x64,共享库也是在64位版本的MATLAB中生成的 我已使用以下代码加载库,然后我收到了错误代码1008:
[DllImport("kernel32.dll",CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr LoadLibrary(string libname);
...
IntPtr handle = LoadLibrary("libName.dll");
if(handle == IntPtr.Zero)
{
int errorCode = Marshal.GetLastWin32Error();
//at this point error code will be 1008.
}
请帮我解决这个问题! 提前谢谢。
答案 0 :(得分:0)
很有可能失败不是直接在libName.dll中,而是在其中一个依赖项中。有很多工具可以诊断出这样的DLL加载问题: