Wikia

Mono Wiki

Detecting if program is running in Mono

Talk0
55pages on
this wiki

How can I detect if am running in Mono?

Having code that depends on the underlying runtime is considered to be bad coding style, but sometimes such code is necessary to work around runtime bugs. The supported way of detecting Mono is:

using System;
 
class Program {
    static void Main ()
    {
        Type t = Type.GetType ("Mono.Runtime");
        if (t != null)
             Console.WriteLine ("You are running with the Mono VM");
        else
             Console.WriteLine ("You are running something else");
    }
}


Any other hack, such as checking the underlying type of System.Int32 or of other corlib types, is doomed to fail in the future.

Advertisement | Your ad here

Photos

Add a Photo
22photos on this wiki
See all photos >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki