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

Maser, Dan Dan.Maser at inin.com
Wed Apr 30 18:12:27 EDT 2008


  I've got a situation where my managed app p/invokes to my unmanaged
library.  The unmanaged library also gets used in regular unmanaged
processes.

  The library has some logic that uses the name of the executable.
Which doesn't what I want when it's used via the interop.  For example
when the library is used from "my_regular_program.exe" it generates an
output file of "my_regular_program.output".  When I interop to that same
library and run under mono using the command line "mono my_assembly.exe"
the library generates "mono.output" when naturally I'd prefer
"my_assembly.output".

  Is there a preferred way to determine whether the process is running
under mono?  I could string-match the executable name but that won't
catch places where people compile mono with a more descriptive name such
as "/usr/local/bin/mono-v1.9" or something like that.

  Thanks in advance for any ideas!
    Dan



More information about the Mono-list mailing list