I have a need to pass an array from a C# library to a legacy MFC C++ application.
The c# function in a class marked as [ComVisible(true)] is:
public void WriteMemory(byte[] data) { ... }
I create a type library and import it in to the MFC C++ application by using the visual studio class wizard to add a class (MFC class from type library), which produces a "Machine generated IDispatch wrapper class", the code for the function is:
void WriteMemory(SAFEARRAY * data) { static BYTE parms[] = VTS_NONE ; InvokeHelper(0x60020007, DISPATCH_METHOD, VT_EMPTY, NULL, parms, data); }
This results in the following error:
error C2440: 'initializing' : cannot convert from 'int' to 'BYTE []'
It seems likely that I would need to add another parameter for the length of the array - hopefully there is some attribute that I could use for this?
Any suggestions on how to massage the generated code to fix this would be greatly appreciated.