[Mono-list] Detecting mono version

Erik Renes keenriser at planet.nl
Wed Feb 20 07:32:34 EST 2008


Hi All, 

I am wondering if there is a way to detect the mono runtime version. 
I am trying to detect the version to be able to gracefully handle the known
issues in windows.forms implementation (my app has serious issues on 1.2.3,
but works fine on 1.2.4 upwards). 

I have found that the Mono.Runtime class has a method called
"GetDisplayName", which returns 'Mono 1.2.4' and seems like a relatively
solid way to detect the version, however, the Mono.Runtime class is
internal, and so is the method. So I cannot be sure if this will continue to
work on newer or older versions of Mono.  

Is there any 'supported' way to detect the mono version? Or another way to
achieve my goal of graceful degredation?

My current code (proof of concept): 
  Type t = Type.GetType("Mono.Runtime");
  MethodInfo mi = t.GetMethod("GetDisplayName", BindingFlags.NonPublic |
BindingFlags.Static );
  string s = (string)mi.Invoke(null, null);
  if (mi!= null)
    Console.WriteLine(s);

Best Regards,
Erik Renes



More information about the Mono-list mailing list