我是这样做的在FILE- >NEW- >PROJECTS中选择"WIN32 Dynamic-Link Library"在Project Name中输入 "a"按OK2.在FILE- >NEW- >FILES中选择C++ SOURCE FILE,在FILE中输入a.cpp,按OK在FILE- >NEW- >FILES中选择TEXT文件,在FILE中输入a.h,按OK 在FILE- >NEW- >FILES中选择TEXT文件,在FILE中输入a.def,按OK
在 a.cpp里面
int add(int a,int b){ return (a+b);
}
在 a.h 里面
int add(int a,int b)
然后我生成了a.dll文件
3)我建立了一个c#工程 testdll
把a.dll copy到testdll\bin\debug下面
在程序里面加入 [DllImport("a.dll",EntryPoint="add")]
public static extern int add(int a,int b);然后我做一个事件
private void button1_Click(object sender, System.EventArgs e)
{
textBox1.Text =add(1,2).ToString();
}报一下错误
未处理的“System.EntryPointNotFoundException”类型的异常出现在 testdll.exe 中。其他信息: 无法在 DLL a.dll 中找到名为 add 的入口点。
以上我错在哪里,谢谢!!!了
在 a.cpp里面
int add(int a,int b){ return (a+b);
}
在 a.h 里面
int add(int a,int b)
然后我生成了a.dll文件
3)我建立了一个c#工程 testdll
把a.dll copy到testdll\bin\debug下面
在程序里面加入 [DllImport("a.dll",EntryPoint="add")]
public static extern int add(int a,int b);然后我做一个事件
private void button1_Click(object sender, System.EventArgs e)
{
textBox1.Text =add(1,2).ToString();
}报一下错误
未处理的“System.EntryPointNotFoundException”类型的异常出现在 testdll.exe 中。其他信息: 无法在 DLL a.dll 中找到名为 add 的入口点。
以上我错在哪里,谢谢!!!了
public static extern int GetApiFunction(
string strParaA,
StringBuilder strParaB,
int intParaC,
out int intParaD,
bool blnParaE);C++数据类型和C#的部分对应关系:C++ 输入输出 C#
==================================
char chr[255] O StringBuilder
KCA_DIR I int
LPCSTR I string
int I int
LPSTR O StringBuilder
int* O out int
DWORD I int
DWORD* O out int
BOOL I bool
Rc_DBMgr I IntPtr
long* O out long