C#System.Environment.OSVersion返回错误的版本 [英] c# System.Environment.OSVersion returns wrong version
问题描述
采用windows 10,从Windows升级8 => 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.
我想正确的操作系统版本,因为我登录一个用户代理字符串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?
推荐答案
视窗10返回该字符串,除非你宣布你应用程序是兼容的使用清单。要做到这一点添加 app.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
这篇关于C#System.Environment.OSVersion返回错误的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!