Vb.net 从dll导入函数时System.EntryPointNotFoundException

Vb.net 从dll导入函数时System.EntryPointNotFoundException,vb.net,dll,Vb.net,Dll,我有一个用VC++创建的Dll。我非常确定Dll是可以工作的,因为当我将它导入到用VC++编写的测试程序中时,它可以工作并提供正确的数据 但当我尝试在VB.Net测试程序中使用它时,它会抛出System.EntryPointNotFoundException 所有Dll函数都使用stdcall 下面是VB.NET测试程序的源代码: Public Class Form1 Public Declare Function func Lib "dll.dll" () As Integer

我有一个用VC++创建的Dll。我非常确定Dll是可以工作的,因为当我将它导入到用VC++编写的测试程序中时,它可以工作并提供正确的数据

但当我尝试在VB.Net测试程序中使用它时,它会抛出System.EntryPointNotFoundException

所有Dll函数都使用stdcall

下面是VB.NET测试程序的源代码:

Public Class Form1
    Public Declare Function func Lib "dll.dll" () As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = func().ToString()
    End Sub
End Class
这是DLL的源代码

#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
__declspec(dllexport)int _stdcall func();

BOOL APIENTRY DllMain(HMODULE hModule,DWORD l_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}
int _stdcall func()
{
    return 123;
}
#包括
#定义WIN32_精益_和_平均值
#包括
__declspec(dllexport)intu stdcall func();
BOOL APIENTRY DllMain(HMODULE HMODULE、DWORD l_原因、LPVOID LPREFERED)
{
返回TRUE;
}
int_stdcall func()
{
返回123;
}

有人能帮忙吗?

没关系,我想出来了。我需要在声明中添加一个别名

我在dll上运行了dumpbin并找到了导入名称

所以我的申报名称应该是:

Public Declare Function func Lib "dll.dll" Alias "?func@@YG_NXZ" As Integer