Passing an array of bytes from C++ to C#
Hi All,
I am trying to write a C# program to call a routine in managed C++.
In the routine, the C# program passes a delegate to the managed C++.
The delegate looks like this in c++:
public __delegate void FoundPidDelegate (
unsigned char pData __gc[],
);
My C# routine looks like this:
static private void MyFoundPidFunction (byte []pData)
The C++ program should call the delegate and pass it an array of bytes (or at least the address of an array of bytes).
In C++ I am allocating the memory like this:
unsigned char arrManaged __gc [] = new unsigned char __gc[iDataLen];
Then I call the C# delegate routine like this:
m_pFoundFunc(arrManaged);
When I arrive back in my C# program, the pData array only has ONE
element (a correct one) and if I try to look at pData[1], I get an error.
What am I doing wrong?
Thanks!
Josh