I have device with C++ DLL interface and I should create C# class to control it. I have no problem with (dis)connecting to this device, but I could not get read function :
Definiton of function in interface is :
bool Driver_Read(int DeviceNo, unsigned char *pReadBuf, unsigned long ReadLen, unsigned long *pReadLen)
I did som research, and I have found that this code should work :
[DllImport("..\\..\\..\\..\\Driver.dll")]
public static extern bool Driver_Read(int deviceNo, StringBuilder pReadBuf, ulong readLen, ref UInt32 pReadLen);
But when I run it, I get an AccessViolationException : "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Lots of people had similar problem, but nothing was helpful for me. Do you know, where could be the problem? Thanks in advance.