Search code examples
c#c++dllinteropidispatch

What are my options for C++ DLL to call a C# DLL?


I have a C++ DLL that needs to call a function (pass a value, return a value) in a C# class library.

Is my only option to give the C# DLL a COM interface and call it from C++ with IDispatch?

Is this the best method?


Solution

  • Couple of options available for you here

    1. Use a mixed mode C++/CLI assembly as a bridge between the C++ and C# DLL
    2. Use the a COM bridge by exposing several of the key C# types as COM objects. This can then be accessed via the C++ code by normal COM semantics