Windows 8.1 版本在未提升时返回为 6.2 (Win 8.0),但在提升时返回 6.3 (Win 8.1).为什么? [英] Windows 8.1 version returned as 6.2 (Win 8.0) when not elevated, but 6.3 (Win 8.1) when elevated. Why?

查看:17
本文介绍了Windows 8.1 版本在未提升时返回为 6.2 (Win 8.0),但在提升时返回 6.3 (Win 8.1).为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 8.1 上运行的 C# 应用程序中调用 Environment.OSVersion.Version 当我以普通(非管理员)帐户运行时返回 6.2(即 Windows 8),但当我以管理员身份运行时返回 6.3(Windows 8.1).

Calling Environment.OSVersion.Version in my C# application running on Windows 8.1 returns 6.2 (which is Windows 8) when I run as a normal (non-administrator) account, but 6.3 (Windows 8.1) when I run as administrator.

我的清单确实包括与本文所述的 Windows 8.1 的兼容性http://msdn.microsoft.com/en-us/library/windows/desktop/dn481241%28v=vs.85%29.aspx,但是当我以提升的权限运行时,我只能得到正确的版本号.知道为什么吗?

My manifest does include compatibility for Windows 8.1 as per this article http://msdn.microsoft.com/en-us/library/windows/desktop/dn481241%28v=vs.85%29.aspx, but I only get the correct version number when I run with elevated privileges. Any idea why?

我的清单:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
        <!-- Windows 8.1 -->
        <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
        <!-- 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 10 - add once tested-->
        <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>-->
    </application>
  </compatibility>   
</asmv1:assembly>

版本号:http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx

类似问题:

为什么是操作系统.版本报告 Windows 8.0 for Windows 8.1?

我该怎么办在桌面应用程序中检测 Windows 8.1

好的 - 也许我可以缩小这个问题的范围.如果我从带有调试器的 Visual Studio 运行我的应用程序,我会看到这个问题(即它报告 6.2 = Windows 8).但是,如果我在没有调试的情况下启动应用程序(没有 vshost),那么我看不到问题(即它报告 6.3 = Windows 8.1).

OK - maybe I can narrow this problem down. If I run my application from Visual Studio with the debugger attached I see this problem (i.e. it reports 6.2 = Windows 8). If, however, I start the application without debugging (no vshost) then I do not see the problem (i.e. it reports 6.3 = Windows 8.1).

问题是manifest 是内置在我的应用程序的exe 中,但执行进程是vshost 包装器,它没有报告与Windows 8.1 兼容的manifest 吗?这对我来说很有意义,但这是奇怪的行为.这实际上意味着在调试您的 app.manifest 文件时是无用的.

Is the problem that the manifest is built into my application's exe, but the executing process is the vshost wrapper, which does not have a manifest that reports compatibility with Windows 8.1? That makes sense to me, but it's odd behaviour. It effectively means that when debugging your app.manifest file is useless.

推荐答案

我找不到来自 Microsoft 的任何支持证据,但是使用和不使用托管进程调试我的应用程序会导致不同的行为.我的结论是托管进程有自己的清单,这与您的应用程序的清单不同.因此,操作系统将不会看到"操作系统.至少有一些清单设置,例如操作系统兼容性.

I cannot find any supporting evidence from Microsoft, but debugging my application with and without the hosting process results in different behaviours. My conclusion is that the hosting process has its own manifest, which is different your application's manifest. As such the operating system will not "see" at least some of your manifest settings such as operating system compatibility.

  • 如何禁用托管进程:

  • How to disable the hosting process:

http://msdn.microsoft.com/en-us/library/ms185330.aspx

有关调试过程执行的操作的信息(以及因此禁用它会丢失的内容):

Info about what the debugging process does (and therefore what you'll lose by disabling it):

http://msdn.microsoft.com/en-us/library/ms242202.aspx

http://msdn.microsoft.com/en-us/library/ms185331.aspx

这篇关于Windows 8.1 版本在未提升时返回为 6.2 (Win 8.0),但在提升时返回 6.3 (Win 8.1).为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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