[Mono-dev] Mixed Mode Assemblies
Tom Spink
tspink at gmail.com
Wed Jul 20 09:14:58 EDT 2011
On 10 July 2011 06:28, arkain <kingmph at gmail.com> wrote:
> So it looks like you guys are saying that allowing mono to create
> mixed-mode
> assemblies is possible given the following constraints:
>
> 1. The .NET metadata must always be found in a PE container.
> 2. A mixed mode assembly must always be a native format library so as to
> allow native programs to load them.
> 3. The PE container for the managed portion of the assembly should be
> contained as a resource of the native format library in a mixed mode
> assembly
> 4. The mixed-mode assembly should also load the necessary mono assemblies
> when loaded from a native application.
>
> With so many of you marking this as an "interesting exercise", is there any
> chance that this to date missing feature will find its way into a near
> future release?
Hi Guys - if you're still watching this thread,
So I may have done something brilliant - or something terrible. I don't
quite know yet - I need your feedback to see if I'm heading along the right
lines.
What I've done is to create a tool that creates a shared library with an
embedded PE assembly inside. The shared library exports symbols that
pertain to methods of the assembly, and when you link against this shared
library, in a native application, you can then call those methods, without
having to bother with using Mono's embedding API.
Essentially, a bunch of method stubs are created that when called ensure the
runtime is initialised, the assembly loaded (from inside the shared library)
and then locate and call the appropriate method. After the runtime has been
loaded, the first few bytes of the method are overwritten with NOPs to
ensure the runtime isn't loaded twice.
The symbols exposed take the form of 'Namespace_Class_MethodName', which
just works for static methods, but to call instance methods, you construct
the class with a call to a 'new_Namespace_Class' function, then pass in the
object instance as the first member.
At the moment, the Makefile is more automated than the code generator, but
if this seems like a worthwhile direction to head in, let me know and you
can give me some feedback on my (rudimentary) implementation.
Anyone interested at all? Or am I barking mad^H^H^Hup the wrong tree?
-- Tom.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110720/93530d0e/attachment.html
More information about the Mono-devel-list
mailing list