c#调用c++ System.DllNotFoundException

来自http://tunps.com/1329898212

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);

About tunpishuang

just 4 fun·····
This entry was posted in 未分类. Bookmark the permalink.

One Response to c#调用c++ System.DllNotFoundException

  1. Pingback: System.DllNotFoundException | 逝水年华

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>