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

Kornél Pál kornelpal at hotmail.com
Tue May 31 10:45:15 EDT 2005


>From: "Ben Maurer"
>> 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).

OK, it works, but is a hack.:) Requires UnmanagedCode permission, creates a
new process, it is slow, the output has to be interpreted, ...

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

It's true, that the functionality that is implemented in the runtime and is
called by assemblies using InternalCall cannot be used on other runtimes.
I recommend detecting runtime type using internal classes in mscorlib.dll
because non InternalCall methods outside mscorlib.dll can simple be used on
other runtimes and public classes that are specific for a runtime can be
implemented by other runtimes even if the assembly cannot be simply copied
to provide compatibility with other runtimes. Using internal classes is good
because it's very unlikely to use two class library the same internal class.
And if it has specific name like MonoType you can make sure that the name it
won't be used by other runtimes.

Kornél




More information about the Mono-devel-list mailing list