[Mono-dev] System.PlatformID

Jonathan Pryor jonpryor at vt.edu
Mon Sep 20 22:24:07 EDT 2010

On Mon, 2010-09-20 at 18:06 -0400, Nicholas Salerno wrote:
> When I query System.Environment.OSVersion.Platform on Linux I get a
> value that will equate to 128.  Yet, this is not in the source code
> definition for the PlatformID enum.

It means you're running in the 1.0 profile.  If you were running under
the 2.0 profile, you'd get 4 (PlatformID.Unix).  See:



        The first versions of the framework (1.0 and 1.1) didn't include
        any PlatformID value for Unix, so Mono used the value 128. The
        newer framework 2.0 added Unix to the PlatformID enum but,
        sadly, with a different value: 4 and newer versions of .NET
        distinguished between Unix and MacOS X, introducing yet another
        value 6 for MacOS X.

> Question: is 128 supposed to mean Linux?

It means Unix under the 1.x .NET profile; under the .NET 2.0 profile,
PlatformID.Unix (4) is returned.

> I am wondering if there is a better way or if this is all that can be done.

Targeting .NET 2.0+ will help (no 128 value), but only so much (there's
still distinct PlatformID.Unix and PlatformID.MacOSX values), so
preferable (normally) are feature checks, not platform checks.

Feature checks are also more useful anyway, as a feature may be added in
some version of a platform, and (based on reading years of Dr. GUI
articles in MSDN) platform version detection and handling is HARD.  You
would not believe the number of errors applications make doing that...

> Also, what if Microsoft suddenly came out of nowhere and said that 128
> will map to AIX?

I would laugh.  A lot.  (AIX?!  Seriously?)

The matter still has a theoretical nature, which can be answered thus:

More specifically, Mono 2.6 is the last release with 1.x profile
support, and thus is the last version that will return 128 for
PlatformID on Unix platforms.  (Plus, most actual apps have been 2.0
apps for quite some time.).  Mono 2.8 is 2.0+ only, and thus will never
return 128.

Furthermore, 2.6 is only getting bug fixes (if that), not feature fixes,
so even if Microsoft added a new enum value, only mono master will
actually receive the value, not 2.6 (or likely 2.8, at this point).

Thus, in practice, it's not really worth worrying about.

 - Jon

More information about the Mono-devel-list mailing list