[Mono-list] How best to detect if running in mono from an unmanaged library?

Chris Howie cdhowie at gmail.com
Wed Apr 30 21:09:00 EDT 2008


On Wed, Apr 30, 2008 at 7:19 PM, Robert Jordan <robertj at gmx.net> wrote:
>  For unix:
>
>  #include <dlfcn.h>
>
>  /* let's assume this is a function exposed to mono: */
>  void test ()
>  {
>         /* get the address of one of mono's API functions */
>         void *p = dlsym (NULL, "mono_runtime_invoke");
>         if (p) {
>                 inside mono ...
>         }
>  }
>
>  The code for Windows is slightly complicated. See
>  mono/utils/mono-dl.c:w32_find_symbol().

Hmm, dlsym, clever.  Certainly not something I would have immediately
thought of.

Just an idea: does mono (or MS.NET) set any environment variables?
I'm sure those could be tested in a far more portable fashion.

-- 
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers


More information about the Mono-list mailing list