This question has been asked before, but I never found a truly satisfying solution -
I have a class library written in C#, and I want to call it from a legacy native
If you want to do this cross platform, I would recommend going with a 100% Mono approach.
Mono has a clean Embedding API which works on Linux and Windows.
With .NET 5.0 (the successor of .NET core) this is now possible to call C# from C++ in a cross-platform way without using Mono. Please see the solution explained in this Github issue using DNNE to generate a shared library and GCHandles to access C# objects.
With this you get a shared library that can be used from C or C++. Note that this will give a C-like API (no objects, like when using extern C
in C++), in the future there may be tools like SWIG for C++ to overcome this limitation.