I have a C dll that I am writing a .NET wrapper for. Other functions that don't involve string-like types work. If i try to pass it as a string back to the C dll, then it gives me a Stack Imbalance error. Same goes for uint, IntPtr, and char[]. Anyway, Here is the function declaration in the API manual:
HENTRY Open2(const TCHAR *pszPort)
And here is my DllImport & function (APILIB is a constant declared earlier)
[DllImport(APILIB, PreserveSig = true)]
private static extern HWKBENTRY Open2(ref char pszPort);
public static HWKBENTRY WkbOpen(string pszPort)
{
//translate
byte[] arg2 = System.Text.Encoding.Defau
lt.GetByte
s(pszPort)
;
return Open2(ref arg2[0]);
}
This works... except for one problem. I need to be able to pass a null pointer. Passing a null does not work. Passing a ref to a 0 byte does not work. I'm pretty lost on this one,
Thanks
Chris
Start Free Trial