Passing an array of Structures from C# to C++(COM)?

You're using a pointer of pointer so you just need to increase the offset ( nElemOffs ) by the size of the pointer and not the size of the struct and dereference it.

You allocate the memory for the array on the managed side (10 elements) but you don't pass the number of elements in the array to the unmanaged side. The marshaller has no way to determine that you want to marshal 10 elements and the unmanaged code don't know the size of the buffer it is writing to. You can use MarshalAsAttribute.

SizeParamIndex to provide information to the marshaller about the size of the array. Also have a look at the article Default Marshaling for Arrays. Given the nature of your API you could change it so that the memory is allocated on the unmanaged side.

You would have to use a safe array or an hglobal to allow the memory to be freed on the managed side.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions