针对.NET Framework 3.5的我的C#程序无法检测到Windows 8.1操作系统的正确版本:当6.3.9600是正确值时,将返回6.2.9200。
Console.WriteLine(System.Environment.OSVersion.Version); // prints out 6.2.9200我找到了这个帖子什么是Windows 8.1的操作系统版本? 提到了目前被打破的链接。
我该怎么做才能获得正确的价值?
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.9200I 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?
最满意答案
添加自定义应用程序清单(右键单击可执行项目 - >添加 - >新项目... - >查找应用程序清单文件)并在其compatibility部分中取消注释元素:
<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>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>更多推荐
发布评论