I am importing a function from an unmanaged DLL in C #. The signature of a C ++ function is as follows
int RF_PowerOnEx(int nDev, int nCardType, DWORD* pdwRXSize, BYTE* lpbRXData)
I import it as follows
[DllImport("TP9000.dll")] public static extern int RF_PowerOnEx(int nDev, int nCardType, out int pdwRXSize, out byte[] lpbRXData);
However, this gives me a System.AccessViolationException exception. I have successfully imported other functions besides this specific one. Both pdwRXSize and lpbRXData are processed as output. The integer and buffer are initialized, then passed to the function, which then fills the buffer. Help!!!! It seems I can pass the input parameters to the DLL, but I cannot get the output parameters. I tried passing the Stringbuilder object to no avail. Can anybody help me? Thanks!
Edit: Typo
source share