[Mono-devel-list] Determine the name and/or kind ofCLI runtime environment

Kornél Pál kornelpal at hotmail.com
Tue May 31 07:31:46 EDT 2005

>From: "Ben Maurer"
> The name of the runtime alone isn't that useful. You'd probably want the
> version of Mono as well.

You are right.:)

> Probably the best way to do this is to test if `basedir typeof
> (object).Assembly.Location`/mcs.exe is there (using c# + bash :-), and
> if it is to execute that with --version. (I guess you need to test for
> gmcs.exe too, since that is what will be there for 2.0...)

As I noticed Environment.Version is the real version on .NET Framework.
Portable.NET returns it's own real version number that may be a wrong
decission but according to the specification this property returns the
version of the runtime.

Mono returns constant version numbers taken from .NET Framework. I don't
think this is a good choice as applications shouldn't rely on
Environment.Version, it is for informational purposes only.

It there a way to obtain the version form the runtime using P/Invoke or some
managed interface?

> If you want a simpler test, being able to load Mono.Posix via reflection
> would be a pretty good one. Much better than depending on an internal
> type like MonoType...

I don't think so. The type used for detection has to be in mscorlib.dll as
it is the only assembly that is runtime dependent, so each runtime has it's
own implementation and cannot be used on other runtimes. The type has to be
internal as public types are used to expose functionality, so they may be
included later in other runtimes to provide compatibility with the others.
MonoType is a good choice as has been ther for a long time and it's name is
specific to Mono so I am sure it will not be used in other runtimes.


More information about the Mono-devel-list mailing list