简体   繁体   中英

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

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM