dom_perron
3/19/2007 4:58:00 PM
Hi,
I need to pass a byte array from a C# dll to a C++ ActiveX(MFC). I
implemented this but when a call the function from the C++ code, I
always get a SafeArrayRankMismatchException:
C# implementation:
void GetImageInByte([In, Out, MarshalAs(UnmanagedType.SafeArray,
SafeArraySubType = VarEnum.VT_UI1)]ref byte[] i_imageArray);
..tlh:
virtual HRESULT __stdcall GetImageInByte (
/*[in,out]*/ SAFEARRAY * * i_imageArray ) = 0;
C++ call:
HRESULT hr = CoInitialize(NULL);
IMyObjectPtr pIMyObject(_uuidof(MyObject));
long lResult = 0;
SAFEARRAY* pSa = 0;
lResult = pIMyObject->GetImageInByte(&pSa); //I got the exception
here...
CoUninitialize();
Does someone has any idea? I search a lot on the net about that but I
don't find a solution...
Thanks
Dominique