Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I do in my C# program to detect the correct OS version for Windows 8.1, using .NET Framework 3.5?

Tags:

c#

.net

windows

My C# program, targeting .NET Framework 3.5 is unable to detect the correct version for Windows 8.1 OS: 6.2.9200 is returned when 6.3.9600 is the correct value.

Console.WriteLine(System.Environment.OSVersion.Version); // prints out 6.2.9200

I found this thread What is the OS version for Windows 8.1? which mentions a link that is currently broken.

What should I do to the program to obtain the correct value?

like image 970
york'ker Avatar asked Dec 08 '25 10:12

york'ker


1 Answers

Add custom application manifest (right click executable project -> add -> new item... -> find application manifest file) and uncomment elements in its compatibility section:

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
    </application>
  </compatibility>
like image 129
max Avatar answered Dec 10 '25 00:12

max



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!