Search code examples
c#c++wcfcom-interop

WCF COM Interop With Complex Types


I want to create a WCF service with COM Interop with which I need to pass complex data. Preferrably an array of custom class objects. I am not sure how to achieve this and there is a lack of decent examples.

I only found one similar question on Stackoverflow here

Calling C# From Unmanaged C++ Passing Or Returning "Complex" Types

However, the solution was to just use a C++/CLI dll instead but this is not an option for me. The C++ application that will call it statically links the C++ runtime and I have been told that this mustn't be changed.


Solution

  • I want to create a WCF service with COM Interop

    OK, but what direction do you want the call to go? For COM -> .Net you need to create a COM Callable Wrapper. For .Net -> COM you need to create a Runtime Callable Wrapper.

    It sounds like you are trying to call .Net from COM, but then this begs the question why are you trying to call a WCF service via interop? If you want to call the service, then consume the service endpoint and call them.