dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]Why is Environment.OSVersion hardcoded to 5.1.2600.0?


From: Rhys Weatherley
Subject: Re: [DotGNU]Why is Environment.OSVersion hardcoded to 5.1.2600.0?
Date: Wed, 21 Apr 2004 21:45:55 +1000
User-agent: KMail/1.4.3

On Wednesday 21 April 2004 08:39 pm, Mark Easton wrote:
> Guys,
>
> I've been trying to understand why the System.Environment.OSVersion
> property is hard coded to 5.1.2600.0 but need someone less naive than
> myself to show me the light.
>
> I know it used to be 0.0.0.0 and that it now matches Mono's
> implementation, but I don't fully understand why it has to be hard
> coded.  The best I've been able to come up with is that because some
> OSes like GNU/Linux don't have strict OS version numbers (where I guess
> the closest thing to an OS version number if the kernel build), although
> since Windows and MacOS do have strict version numbers I'm guessing the
> value could be grabbed from an internal call at some point.

The version number exists solely to fool C# programs written by dumb 
programmers who think that all the world is Windows. :-)  It pretends to be a 
standard WinNT version to fool these programs.  A fake number was better than 
a meaningless one (a Linux kernel version number would mean nothing to such 
dumb programs and smart programs won't depend on the number anyway).

Pnet's "OSVersion.ToString()" will include the autoconf host name (e.g. 
"i686-pc-linux-gnu") on Unix platforms, which can give more accurate 
information about what the real platform is than a version number can.

There's no foolproof system for getting a version identifier across systems. 
Only Microsoft seems to think that versions come in monotonically increasing 
4-part numbers and that one number can uniquely identify everything on a 
platform.  Most platforms don't come from a single monopoly vendor - they are 
made up of pieces from multiple sources, each with their own versions.

Smart programmers use API probing: try a number of different calls until one 
works, and intuit the platform behaviour from that (e.g. autoconf under C, or 
PInvoke probing under C#).  Or they don't use OS-specific API's at all.  By 
hard-wiring the version, I'm encouraging programmers to be smart. :-)

Cheers,

Rhys.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]