I need to expose some C++ classes to C# (I am building on Linux, using mono, so COM is not an option)
The evidence I have gathered so far suggests that the best way to approach this is:
I have the following questions:
You can't do C++/.NET classes on Linux using Mono. Mono doesn't support Managed C++ or C++/CLI, so there is no way to "Write a wrapper C++.Net class around the ISO C++ class".
Your best option for this is to generate a C API for your C++ class, which can be accessed via Platform Invoke.
That being said, one option for easing this is to use SWIG to generate the wrappers for you. It supports generation of C# wrappers from C++ classes (as well as wrappers to other languages), and works well on Linux/Mono.
Edit:
For an official "Mono doesn't support mixed mode C++/CLI", see the Languages page:
It's important to note that any language that compiles to pure IL should work under Mono. Some languages such as Microsoft's Managed C++ do not always compile to pure IL, so they will not always work as expected, since they are not truly platform independent.
C++/CLI for native interop requires non-pure IL, so it will not work on Mono.
Mono has recently made some pretty big strides with C++ interoperability in CXXI (pronounced sexy).
From this posting, the short story is that the new CXXI technology allows C#/.NET developers to:
CXXI is the result of two summers of work from Google's Summer of Code towards improving the interoperability of Mono with the C++ language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With