[Mono-dev] Multiple Monos in a single process
robertj at gmx.net
Wed Sep 21 15:10:23 EDT 2011
On 21.09.2011 20:30, Joe Dluzen wrote:
> 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
AFIK, there is no such function, but you could use this test:
if (mono_get_root_domain ())
// runtime is already initialized
>> 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?
You should avoid this if you don't control Mono on the target
machine, because it won't work with a statically linked Mono.
If you still believe you need this, then provide a stub
for the managed application: a simple native app that
embeds Mono and launches the managed application.
This way you can be sure that a dynamically linked
libmono will be used.
>> Are there any complications that I should be aware of when the
>> SO+managed code is ready to be unload from the process?
Don't try to unload the runtime. While API-wise supported,
there are still issues with the unloading.
>>> 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.
More information about the Mono-devel-list