[Mono-list] How can the assembly check the OS it's on?

Jonathan Pryor jonpryor@vt.edu
07 Mar 2003 16:42:59 -0500


OSVersion just provides access to a PlatformID and a Version.

PlatformID is an enumerated type.  The .NET version only goes into
detail for Win32 platforms (Win32S, Win32Windows, Win32NT).  I don't
think .NET mentions Unix *at all*.  If it does, it certainly won't
mention the myriad different flavors of Unix running around.

Mono can extend PlatformID (in fact, it added a Unix value), but if an
extended value is used under .NET, the results of expecting an extended
value are likely undefined.  So this isn't a portable, long-term
solution.

 - Jon

On Fri, 2003-03-07 at 16:31, Daniel Morgan wrote:
> What about OSVersion and other properties found in System.Environment?
> 
> -----Original Message-----
> From: mono-list-admin@lists.ximian.com
> [mailto:mono-list-admin@lists.ximian.com]On Behalf Of Jonathan Pryor
> Sent: Friday, March 07, 2003 4:25 PM
> To: Charles-Louis
> Cc: Mono List
> Subject: Re: [Mono-list] How can the assembly check the OS it's on?
> 
> 
> Easiest way I'm aware of is to check
> System.IO.Path.DirectorySeparatorChar.  It's '\\' on Win32, '/' on Unix.
> 
> Alas, I'm not aware of any other way, which pretty much prevents
> checking for Mac OS X vs. Linux vs. Solaris vs. AIX...
> 
> I'd love to hear of a better form of checking.
> 
>  - Jon
> 
> On Fri, 2003-03-07 at 10:44, Charles-Louis wrote:
> > Hi,
> > 
> > I was wondering if it was possible for an assembly to now on which OS it
> > is running?
> > 
> > eg. if I'm running on windows, I'll use the Windows System logs, and if
> > I'm on Linux, i'll use the Linux logs...
> > 
> > I'd like my compiled assembly to detect it, and I'd rather not use an
> > App.config file for this.
> > 
> > Is this possible?
> > 
> > Thanks
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list