c - 在 VB.net 中加载 C DLL 的 EntryPointNotFoundException

标签 c vb.net visual-studio-2010 dll

我花了几个小时试图让这个简单的测试用例正常工作,并在互联网上搜索线索。

我有一个 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 文件传递​​给链接器。像这个截图一样做:

enter image description here

关于c - 在 VB.net 中加载 C DLL 的 EntryPointNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6917842/

相关文章:

c - fatal error : openssl/opensslconf. h:没有这样的文件或目录

asp.net - 附加到进程 w3sp.exe 并选择 AppPool

visual-studio-2010 - 在 Visual Studio 2010 中自动排列 UML 图

visual-studio-2010 - OpenCV:使用具有 SURF 功能的彩色帧的问题

c - 从文件中删除字符串

c - 为什么使用 __attribute__((weak)) 和#pragma weak?

c - malloc 返回内存的空闲范围

vb.net - 当文本框获得焦点时选择文本框的内容

vb.net - Response.redirect 引发 "Thread was being aborted"

.net - 使用线程监听 UDP 广播