[Mono-devel-list] .export Directive in IL

Jonathan Pryor jonpryor at vt.edu
Thu Jun 30 06:17:08 EDT 2005

On Wed, 2005-06-29 at 22:48 -0400, Jonathan S. Chambers wrote:
> Thanks for the answers. I'm just experimenting with methods to call
> managed code from unmanaged code without using COM interop, i.e.
> something that would work on both .Net and Mono. Any advice would be
> appreciated. 

Basic question: "who" is starting the process -- managed or unmanaged
code.  Put another way: is the unmanaged code a program or a library?

If the unmanaged code is a library and .NET is starting the main
program, then you should use callbacks.  Delegates are marshaled as
function pointers, so you would create a C interface to allow managed
code to set a group of callback functions, and then the C code would
invoke the function pointers to call managed code.  This is portable
between both Mono & .NET.

Do remember to keep the delegates in scope so that they aren't GC'd
while the unmanaged code knows about them. :-)

If the unmanaged code is a program, you're out of luck: there is no
portable solution.  .NET uses COM Interop, while Mono provides an
embedding API that allows creation & invocation of managed objects from
unmanaged code.  See:


 - Jon

More information about the Mono-devel-list mailing list