[Mono-list] interesting discussion regarding managed dynamic libraries

Ian MacLean ianm@ActiveState.com
Thu, 16 Dec 2004 17:18:07 +0900

Pieter Breed wrote:

>Hi All,
>I recently tried to start a discussion on the
>microsoft.public.dotnet.general newsgroup. To my dismay nobody seemed
>interested in discussing something which I think might be cool.
>The idea is this:  If you write a managed (hereafter .net for brevity)
>class library could you not "export" certain annotated static methods
>in such a way the a normal C-style application could use those
>I think one can accomplish this by actually only exporting a standard
>stub with the correct name/symbol that another application can link
>to. This stub then invokes the .net runtime when called, does the
>marshalling thing, and pass control to the "exported" static method
>which now executes under the runtime.
>When the method finishes, one can do the reverse for return values and
>reference parameters.
>To my though at least, this seems similar to what happens when you
>execute a .net application in the standard way.
>What do you all think of such a scheme?
since managed dlls are PE files this is certainly feasible for windows. 
However short of using wine you won't have much luck linking such a 
"native dll" from a unix c app.

In general you're probably better off writing a wrapper library in c 
that hosts the runtime and loads the managed assembly you want to call. 
There are probably other ways as well.