views:

293

answers:

1

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 C++ application. The host application is truly native, compiled on Windows & Linux, its a console application. So how can I make it call the C# class library, assuming using Microsoft .NET on Windows, and Mono on Linux.

I have looked at SWIG and wrapping with COM interfaces on Windows, but is there a standard recognized solution that works cross platform? i.e. that is generic, works with both Microsoft .NET and Mono, a write once use everywhere implementation.

Solutions should expose the full class interfaces from the C# domain to the C++ domain.

Similar questions focus only on the Windows solutions, for example -

Call C# methods from C++ without using COM

+2  A: 

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.

Reed Copsey
Good answer, embedding Mono on Windows not really what I was looking for also it all looks very manual. You would have to write a lot of boiler plate code to expose an full interface to a library, it looks time consuming and fragile, reminds me of JNI. I was wondering if there is some sort of automated way, like SWIG or just exposing a COM interface.
titanae
COM works well, but not so well on linux. SWIG is only good for going the other way... Sorry.
Reed Copsey