'System.Runtime.InteropServices.MarshalDirectiveException'

  • Thread starter Thread starter Logan McKinley
  • Start date Start date
L

Logan McKinley

I need to access a function from a dll but am having problems with the
conversion.
the def from the documentation is:
extern "C" __stdcall int tira_get_captured_data_vb ( unsigned char data[],
int* size );

I tried converting that to:
[DllImport("Tira2.dll")] public static extern int
tira_get_captured_data_vb(ref char[] data, ref int size);

and calling it with
char[] Data;
int DataSize = 0;
res = tira_get_captured_data_vb(ref Data, ref DataSize);

but get the following error
'System.Runtime.InteropServices.MarshalDirectiveException'
Additional information: Can not marshal parameter #1: Ansi char arrays can
not be marshaled as byref or as an unmanaged-to-managed parameter.

Thanks in advance,
~Logan
 
Back
Top