April 04, 2006

Passing Int Array from Unmanged to Managed code

Unmanaged VB6.0 Code to C#

Note that you have to pass array without index.

Dim lParms(9) As Long
objNetAsm.GetInfo lParms

Managed C# Code:

In managed C# the array is accessed by refrence.
public long GetInfo (ref Int32[] plParms)

// Note that long in VB is Int32 in C#

UnmanagedVB6.0 to C++:

// Note you have to pass 0th element
cppObj.GetInfo lParms(0)

Unmanaged C++
// Using array pointer
GetInfo (long * plParms)


Some more good info on "Default Marshaling for Arrays"