[Mono-dev] Multiple Monos in a single process

Joe Dluzen jdluzen at gmail.com
Wed Sep 21 14:30:26 EDT 2011


Whoops, forgot to edit subject. This one should make the above email
more apparent.

On Wed, Sep 21, 2011 at 2:13 PM, Joe Dluzen <jdluzen at gmail.com> wrote:
> Thanks Robert, I expected something like that.
>
> Is there an easy way to determine if the runtime has already been
> initted? I would like to use Mono for practically all logic for my
> unmanaged SO needs, yet allow for the possibility that the application
> is managed. I would like to avoid requiring the app to pass some Mono
> handle into the SO to do all its work, though if that's the way it is,
> then that's the way it is. Then comes the issue of versioning the
> runtimes, 2 corlibs being loaded, etc. Should I just stay away from
> this whole thing?
>
> Are there any complications that I should be aware of when the
> SO+managed code is ready to be unload from the process?
>
> Thanks,
> Joe
>
>> Date: Tue, 13 Sep 2011 11:53:07 +0200
>> From: Robert Jordan <robertj at gmx.net>
>> Subject: Re: [Mono-dev] Multiple Monos in a single process
>> To: mono-devel-list at lists.ximian.com
>> Message-ID: <j4n96i$6is$1 at dough.gmane.org>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> On 12.09.2011 22:23, Joe Dluzen wrote:
>>> Hi all,
>>>
>>> let's say I have a C# app A which PInvokes to a native SO/DLL B, which
>>> embeds Mono for basically 100% of its logic. Do bad things happen on
>>> Linux vs Windows?
>>
>> Yes. Under Linux, libmono is statically linked by default.
>> If you p/invoke a library that it turn is linked against
>> libmono, you'll end up with 2 runtime instances.
>>
>> Even if you link libmono dynamically (there is a `configure'
>> switch for this), you must take care to initialize the runtime
>> only once. This means that you can't call mono_jit_init/cleanup
>> from the SO.
>>
>> Robert


More information about the Mono-devel-list mailing list