Steve
Steve

Reputation: 12004

Pass multidimensional (safe)array from C# to COM

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?

Upvotes: 2

Views: 1418

Answers (2)

Hans Passant
Hans Passant

Reputation: 941218

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[][].

Upvotes: 1

Grzenio
Grzenio

Reputation: 36639

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 :)

Upvotes: 0

Related Questions