0

I'm a C# programmer and I want to expand a C++ project with some new functionality. How can I use C# code/libraries in the current C++ project?

I read a lot about this problem but I didn't find good step-by-step answers. I just want to create some funtions/classes in C#, execute this from C++ and read return values like string or int.

I've tried e.g to join C# library and call them from C++ code but this doesn't work.

yacc
  • 2,915
  • 4
  • 19
  • 33
David06
  • 13
  • 2
  • 1
    One option could be to add a C++ class implemented with C++/CLI to the existing C++ project. C++ code can use this class as a bridge to .NET framework. Some C++/CLI books have chapters dedicated to exactly this use case – mvidelgauz Jun 03 '19 at 12:39
  • I am pretty sure there is a way with using native compilation to make a C# DLL works with C++ – Franck Jun 03 '19 at 12:41
  • C# code can be seen/used by unmanaged C++ by publishing the objects in a C# library as COM components. See https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/interop/example-com-class – Steve Todd Jun 03 '19 at 12:43
  • https://stackoverflow.com/questions/778590/calling-c-sharp-code-from-c Check this existing answer out – WebBoy Apr 16 '20 at 23:54

0 Answers0