I have a COM object that takes a 0 bounded safearray of two dimensions. I need to pass this array into my C++ COM object. I can pass the VB6 multidim arrays into the C++ side without a problem, but I have no idea how to set this up in C# so that it will be marshalled correctly. Does anyone know the steps to set up a mulitidimensional array and pass it to COM?
A:
I think you have to generate a standard com interop for your C++ COM dll (e.g. add it as a reference to your c# project). Then I think C# should correctly marshal a standard .Net (multidimentional) array as a com safe array. Just give it a go :)
Grzenio
2010-06-22 15:06:15
No, it marshals it as a single dimensioned array, as the IDL just specifies SAFEARRAY*
Steve
2010-06-22 15:16:20
+1
A:
I'm pretty sure that should work as-is. Just make sure that you pass a true 2-dimensional array, not a jagged array. In other words, pass arr[,] not arr[][].
Hans Passant
2010-06-22 16:54:15