c#调用vc++写的DLL,找不到入口点

roy66 2005-04-04 10:55:10
C#中:
[DllImport(@"E:\code\SerailVcDll\Release\SerailVcDll.dll", EntryPoint="test", CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern int test(int a);

vc++中:
int CSerailVcDllApp::test(int a)
{
return a;
}
...全文
200 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qiezic 2005-05-10
  • 打赏
  • 举报
回复
mark
oceanh 2005-04-29
  • 打赏
  • 举报
回复
dumpbin /exports SerailVcDll.dll
能看到导出函数名吗?
oafoo 2005-04-29
  • 打赏
  • 举报
回复
从托管应用程序调用非托管代码
当调用用户定义的 DLL 中所包含的函数时,有必要将 extern "C" 添加在 DLL 函数声明之前,如下所示:
The function declaration in SampleDLL.h file
extern "C" SAMPLEDLL_API int fnSampleDLL(void);

详见http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/vcwlksysimportattributetutorial.asp

但愿有用!
01230123 2005-04-04
  • 打赏
  • 举报
回复
[DllImport("SerailVcDll.dll")]
真相重于对错 2005-04-04
  • 打赏
  • 举报
回复
vc++ 中引出函数不是标准命名,你使用depends.exe察看一下你的dll的引出函数是什么?
romanticist 2005-04-04
  • 打赏
  • 举报
回复
只有在.def文件中有EXPORTS的才可以找到入口,例如:

; FileZip.def : Declares the module parameters for the DLL.

LIBRARY "FileZip"
DESCRIPTION 'FileZip Windows Dynamic Link Library'

EXPORTS
; Explicit exports can go here
AddFileToZip @1
AddStreamToZip @2
oyljerry 2005-04-04
  • 打赏
  • 举报
回复
dll路径是否正确,函数参数是否正确
roy66 2005-04-04
  • 打赏
  • 举报
回复
用depends.exe查看了一下,引出函数是test。

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧