Im developing a C#.NET application using Visual Studio 2008.
Im having trouble accessing data in a C++ DLL within my solution.
The C++ DLL is called myDLL.dll. Ive defined this in my C#.NET code thus;
static extern int GetArray(UInt32 pBuffer, int Size);
In the C++ source the code is like;
int GetArray(unsigned long* pBuffer, long BufferSz)
int result = 0;
// getValues in a manufacturer DLL. It returns a pointer to "unsigned long*"
pBuffer = GetValues();
In my C++ DLL the GetArray function is exported thus;
__declspec(dllexport) int GetArray(unsigned long* pBuffer, long BufferSz);
I now try and access the values from my C#.NET code. ie.
int size = 1000;
UInt32 pBuf = new UInt32[size];
int = GetArray(pBuf, size);
However I get an exception when I call GetArray. It is
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt"
Can anyone spot why this may not be working? Note we can't put a breakpoint in this particular DLL for some reason. We've spent ages trying to fix this but it seems its a known bug in Visual Studio.