I am porting some VB6 code to VB.net, the code contains a structure containing 1d arrays, 2d arrays and several other variables.
The general structure diagram of Vb.net is under
Public Structure Test
Dim a As Single
Dim b As Single
Dim c As Single
<VBFixedArray(2)> Dim arr1() As Single
<VBFixedArray(2, 2)> Dim mdarr1(,) As Single
<VBFixedArray(4)> Dim arr2() As Byte
<VBFixedArray(4)> Dim arr3() As Short
<VBFixedArray(3, 2)> Dim mdarr2(,) As Integer
Dim d As Integer
Dim e As Decimal
End Structure
DLL call is declared as
Public Declare Sub getState Lib "val.dll" (ByRef state As Test)
Elsewhere on this site, I realized that we must βmarshalβ the structure so that it can be compatible with the unmanaged code that is going to accept it.
However, I still get errors while executing the code, I don't know how to use the class System.Runtime.InteropServices.Marshal.
What would be the proper way to pass this structure to the dll?
EDIT:
Original data type VB6
Public Type Test
a As Single
b As Single
c As Single
arr1(0 To 2) As Single
mdarr1(0 To 2, 0 To 2) As Single
arr2(0 To 4) As Byte
arr3(0 To 4) As Integer
mdarr2(0 To 3, 0 To 2) As Long
d As Long
e As Currency
End Type
source
share