Search code examples
c#c++interfaceclr

Use a C# interface in C++ or use a C++ interface in C#


I'm developping a solution where I have an Interface (in C#) that has to be used by a C++ solution and a C# solution. I would like to know:

What is the best way to achieve this between:

  • A C# interface that I use in my C++ project
  • A C++ interface that I'll use in my C# project

Also could you indicate me how I should proceed for the best solution?


Solution

  • Do you mean managed c++?

    In case of managed c++ it is easy to do, just put interface in separate project(dll) and reference it from c#

    Things become difficult if you want to do the same with not-managed c++

    Than you would need to use COM,PInvoke or some kind of service/socket comunication

    Hope this helps