我花了几个小时试图让这个简单的测试用例正常工作,并在互联网上搜索线索。
我有一个 VS 10 解决方案,其中包含我的 VB.net 项目和一个 VC++ DLL 项目。
在我的 DLL 项目中我有:
json_main.cpp:
#include <Windows.h>
extern "C"
{
void testMethod(int* inVal )
{
*inVal += 5;
}
}
JSON.def:
LIBRARY JSON
DESCRIPTION 'Simple JSON encoder/decoder'
EXPORTS
testMethod
还有我的 VB.net 代码:
<DllImport("C:/inetpub/wwwroot/facebook/AlumniFinder/Debug/JSON.dll", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Sub testMethod(ByRef inVal As Integer)
End Sub
...
Dim var As Integer = 7
testMethod(var)
oLabel.Text = var.ToString
然而,当我尝试运行时,我得到了 EntryPointNotFoundException
。
有人知道我在这里可能做错了什么吗?我尝试在我的 DLL 上使用 dumpbin.exe,但我没有从中获取任何函数名称来确定它正在使用的处理方案
最佳答案
使用 dumpbin/exports
或 Dependency Walker 来检查您是否正在导出函数,因为看起来您没有。
我的猜测是您没有将构建配置为将 .def 文件传递给链接器。像这个截图一样做:
关于c - 在 VB.net 中加载 C DLL 的 EntryPointNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6917842/