System.Environment.OSVersion返回错误的版本 [英] System.Environment.OSVersion returns wrong version

查看:70
本文介绍了System.Environment.OSVersion返回错误的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用从Windows 8升级的Windows 10 => 8.1 => 10当我使用此代码时.

Using windows 10, upgraded from windows 8 => 8.1 => 10 When I use this code.

OperatingSystem os = System.Environment.OSVersion;

os.Version = {6.2.9200.0} System.Version

The os.Version = {6.2.9200.0} System.Version

我读到这是因为它是体现,但我不明白这是什么意思.

I read this was because of the version it was manifested for but I do not understand what that means.

我想要正确的OS版本,因为我正在Web服务上记录用户代理字符串,并且想要正确地识别Windows版本以获得支持.正确报告正确版本的最简单方法是什么?

I want the correct OS version because I am logging a user agent string on a web service, and want to correctly identify the windows version for support. what is the easiest way to get that to correctly report the correct version?

推荐答案

Windows 10返回该字符串,除非您使用清单文件声明应用程序兼容.为此,添加一个 app.manifest (右键单击您的项目-> Add-> New Item-> Application Manifest文件),然后取消注释以下行:

Windows 10 returns that string unless you declare that your application is compatible using a manifest. To do so add an app.manifest (right click your project -> Add -> New Item -> Application Manifest File) then uncomment the following line:

<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

对于Windows Vista到Windows 10,您可以执行相同的操作.所有操作都在同一部分:

You can do the same thing for Windows Vista to Windows 10. All are in the same section:

<application>
  <!-- A list of the Windows versions that this application has been tested on and is
       is designed to work with. Uncomment the appropriate elements and Windows will 
       automatically selected the most compatible environment. -->

  <!-- Windows Vista -->
  <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

  <!-- Windows 7 -->
  <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

  <!-- Windows 8 -->
  <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

  <!-- Windows 8.1 -->
  <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

  <!-- Windows 10 -->
  <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

</application>

现在,当您运行应用程序时,它将报告正确的10.0.*.0版本

And now when you run your application it'll report the correct 10.0.*.0 version

这篇关于System.Environment.OSVersion返回错误的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆