E
Eric Hendriks
// In an unmanaged DLL the following function must be called:
// int VFGeneralize(const BYTE * const * features);
// "features" parameter is supposed to be an array of byte arrays.
// function is Marshaled as follows:
[DllImport("duh.dll", EntryPoint="VFGeneralize", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
static extern int VFGeneralize(byte[][] features);
In C# I have the following:
// Allocate memory to store "Count" references to byte arrays
byte[][] src = new byte[Count][];
// Point the references to existing byte arrays
for( int i = 0; i < Count; i++ )
{
// records is an array of structs. in each record Featurebuffer
points to
// an array of bytes.
src = records.FeatureBuffer;
}
// Try to call the DLL with:
VFGeneralize(src);
The above compiles Ok, but when calling the VFGeneralize function I
get the exception:
An unhandled exception of
type 'System.Runtime.InteropServices.MarshalDirectiveException'
occurred in veriwrapper.dll
Additional information: Can not marshal parameter #2: Invalid
managed/unmanaged type combination (Arrays can only be marshaled as
Array or SafeArray).
How to solve this?
// int VFGeneralize(const BYTE * const * features);
// "features" parameter is supposed to be an array of byte arrays.
// function is Marshaled as follows:
[DllImport("duh.dll", EntryPoint="VFGeneralize", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
static extern int VFGeneralize(byte[][] features);
In C# I have the following:
// Allocate memory to store "Count" references to byte arrays
byte[][] src = new byte[Count][];
// Point the references to existing byte arrays
for( int i = 0; i < Count; i++ )
{
// records is an array of structs. in each record Featurebuffer
points to
// an array of bytes.
src = records.FeatureBuffer;
}
// Try to call the DLL with:
VFGeneralize(src);
The above compiles Ok, but when calling the VFGeneralize function I
get the exception:
An unhandled exception of
type 'System.Runtime.InteropServices.MarshalDirectiveException'
occurred in veriwrapper.dll
Additional information: Can not marshal parameter #2: Invalid
managed/unmanaged type combination (Arrays can only be marshaled as
Array or SafeArray).
How to solve this?