[Mono-devel-list] Best way to use C# from C
jonpryor at vt.edu
Mon Dec 20 18:39:44 EST 2004
On Mon, 2004-12-20 at 12:37 +0000, aza wrote:
> I want to use some managed code components from a C application (that works
> on Linux and Windows) what would be the most efficient way to do this?
Define "best". There are the options you specified, and here are three
1. COM Interop. This is .NET specific. Managed classes can be
exported as COM classes and created/used in the standard COM manner.
See MSDN. This doesn't fit your requirements for Linux+Windows use.
2. Mono's embedding API. Allows creating and using managed classes
from C, and allows adding additional InternalCalls.
Assuming you can use Mono on both Linux and Windows, this will
meet your platform requirements.
3. Platform Invoke. This is the only solution portable between Mono
and .NET. Delegates can be marshaled into a function pointer, which
can then be invoked from C to invoke a managed method. This doesn't
permit creation of arbitrary managed objects from C.
See the recent Mono-list discussion:
If you can live with its limitations, this will also meet your
More information about the Mono-devel-list