【发布时间】:2023-04-11 07:03:02
【问题描述】:
正在使用:Windows 10 64 位和 Visual Studio 2017 Pro。
我构建了一个 Visual-C++ DLL。 config=active(Debug) Platform=Active(Win32) Platform_Target=Windows10
我还构建了一个 VB.NET windows 窗体 GUI。 config=active(Debug) Platform=Active(Any CPU) Target_CPU=Any CPU .NET 4.5.1
DLL 有这个空函数:
extern "C" BASICDLL_API void __stdcall test_empty_function(void)
{
}
VB.NET 有这个 DLL 声明:
Imports System.Runtime.InteropServices
Module main_board_interface
Public Class NativeMethods
<DllImport("MyDll.dll")>
Public Shared Sub test_empty_function()
End Sub
单击此处的 VB.NET 按钮时,VB.NET 调用空 DLL 函数....
Private Sub Button_test_main_board_Click(sender As Object, e As EventArgs) Handles Button_test_main_board.Click
main_board_interface.NativeMethods.test_empty_function() '<<< causes error
在最后一行,我得到这个错误:
System.BadImageFormatException:
'An attempt was made to load a program with an incorrect format.
(Exception from HRESULT: 0x8007000B)'
【问题讨论】:
标签: .net vb.net visual-c++ dll