c#调用c++ System.DllNotFoundException
没找到dll:
An unhandled exception of type 'System.DllNotFoundException' occurred in WindowsFormsApplication1.exe Additional information: 无法加载 DLL“test1.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。
没找到入口点:
An unhandled exception of type 'System.EntryPointNotFoundException' occurred in WindowsFormsApplication1.exe Additional information: 无法在 DLL“test1.dll”中找到名为“max”的入口点。
c++代码,编译为dll
#include <iostream>
#define TEST1_API extern "C" __declspec(dllexport)
TEST1_API int maxxx(int a, int b)
{
return a > b ? a : b;
}
c#代码,调用部分
[DllImport("test1.dll",EntryPoint="maxxx",CharSet=CharSet.Auto,CallingConvention=CallingConvention.Cdecl)] public static extern int maxxx(int a, int b);
Pingback: System.DllNotFoundException | 逝水年华