Saturday, August 30, 2014

Marshalling an Array of struct from DispInterface C++ COM to a C# Client

Hello Peter,


1. You mentioned in the OP that the returned VARIANT contains a SAFEARRAY of DispInterfaces, hence I expected that the MatchedItem structure would be wrapped inside a class that implements the dispinterface.


2. Hence the answer to the question in your last post is : no.


3. Although you can create a SAFEARRAY that contains structures (provided that it is defined with a GUID in the IDL), it cannot be marshaled successfully to .NET if the array is to be contained in a VARIANT.


4. My suggestion is to create a C++ class that implements dispinterface and use it to represent the MatchedItem structure.


- Bio.




Please visit my blog : http://ift.tt/1r6KxsJ


No comments:

Post a Comment