Aaron Franke Aaron Franke - 3 months ago 12
Linux Question

MonoDevelop reports my platform incorrectly on Linux

I'm using Xubuntu 16.04 LTS with MonoDevelop 5.9.6. I have created a console application and this is the only code:

public static void Main (string[] args)
{
Console.WriteLine (new PlatformID());
}


However, in the console, this is the output:

Win32S


Why is it detecting my platform incorrectly? I'm clearly not using Windows.

Answer

PlatformID is an enumeration from System, not a class you can instance so I'm not sure how your code even complies.

If you want OS Version and/or Platform, here is how you can obtain it:

Code Snippet:

var os = Environment.OSVersion;
var pid = os.Platform;
Console.WriteLine($"{os}");
Console.WriteLine($"{pid}");

Output:

Unix 15.6.0.0
Unix