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

Ben Maurer bmaurer at ximian.com
Tue May 31 09:57:43 EDT 2005


On Tue, 2005-05-31 at 13:31 +0200, Kornél Pál wrote:
> >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?

No, not today (other than my --version hack, which actually isn't all
that bad).

> > 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

Not true *at all*. jonp is write about Mono.Posix, it can probably be
used with other runtimes. However, you can't copy eg system.dll between
runtimes and expect it to work.

-- Ben




More information about the Mono-devel-list mailing list