开发者

Pass multidimensional (safe)array from C# to COM

开发者 https://www.devze.com 2023-01-04 03:41 出处:网络
I have a COM 开发者_Python百科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

I have a COM 开发者_Python百科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?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消