我需要在VB.NET中使用 C++ DLL 文件。下面是DLL 文件的转储文件。
D:\Program Files\Microsoft Visual Studio 10.0\VC>dumpbin /exports d:\dll\myssort.dll
Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file d:\dll\ myssort.dll
File Type: DLL
Section contains the following exports for MySort.dll
00000000 characteristics
3D3F006E time date stamp Thu Jul 25 01:00:54 2002
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00001000 MySortA7
Summary
1000 .data
1000 .rdata
1000 .reloc
1000 .rsrc
3000 .text
下面是 Visual Basic 6.0 对象浏览器中显示的函数定义。
Function SortA7(udtArray As udtA7Rec, nTotalItems As Long) As Long
Member of MySort. MySort
Sort the elements of A7-type array
如何在 VB.NET 中调用此方法?
我尝试进行 DLL 导入:
<DllImport("MySort.dll", _
SetLastError:=True, CharSet:=CharSet.Auto)>
Public Function SortA7(ByVal udtArray As MySort.udtA7Rec(), ByVal nTotalItems As Long) As Long
End Function
但这给了我一个错误:
尝试读取或写入受保护的内存。这通常表明其他内存已损坏。