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?

在我的 C# 应用程序 运行ning 上调用 Windows 8.1 returns 6.2(即 Windows 8),当我 运行 作为普通(非管理员)帐户,但 6.3 (Windows 8.1) 当我 运行 作为管理员时。

我的清单 根据这篇文章 http://msdn.microsoft.com/en-us/library/windows/desktop/dn481241%28v=vs.85%29.aspx 包含 Windows 8.1 的兼容性,但我只有在 [=47] 时才获得正确的版本号=] 具有更高的权限。知道为什么吗?

我的清单:

<?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

类似问题:

Why OS.Version reports Windows 8.0 for Windows 8.1?

How can I detect Windows 8.1 in a Desktop application

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

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

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