应用程序默认在Windows Vista上下文中运行

Zai*_*mir 4 operating-system visual-studio-2010 visual-c++ windows-8

我正在Windows 8计算机上测试我的桌面应用程序,我注意到任务管理器详细信息视图中有一个名为"操作系统上下文"的新列.这显示我的应用程序在"Windows Vista"上下文中运行.

我没有在应用程序清单中指定任何内容来强制应用程序在Visual Studio中的此上下文中运行.该应用程序是一个Visual C++应用程序,并在Visual Studio 2010中构建.

不要误解我的意思,应用程序在Windows 8上运行顺畅,所以我不打算解决崩溃或错误.看到这样的事情并想修理它让我感到很恼火.

所以我的问题是如何让我的应用程序在Windows 8下的"Windows 8"上下文中运行?

Rog*_*and 8

好的,我想我在这里找到了答案.它说:

默认情况下,在Windows 7和未来的Windows版本中,清单中没有兼容性部分的应用程序将接收Windows Vista行为

因此,如果您的清单中没有任何内容,Vista就是您所获得的.阅读本文的其余部分,您可以做的最好的是获取Windows 7而不是Windows 8,那么这可能是Store Apps特有的内容吗?

编辑

好的,我终于找到了Windows 8所需的条目:

<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
Run Code Online (Sandbox Code Playgroud)

因此,请尝试将其放入清单的兼容性部分.

我知道你正在使用VS2010,所以这可能会有所不同,但是对于VS2012,我做了以下事情:

  1. 创建了一个新的WPF应用程序
  2. 在Solution Explorer中右键单击项目,然后选择Add New Item
  3. 从列表中选择应用程序清单

将新的清单添加到项目中,并注释掉兼容性设置.删除所有内容的简要示例如下:

<?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"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
  <application>
    <!-- A list of all Windows versions that this application is designed to work with. 
    Windows will automatically select the most compatible environment.-->

    <!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
    <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>

    <!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
    <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>

    <!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
    <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>

  </application>
</compatibility>
</asmv1:assembly>
Run Code Online (Sandbox Code Playgroud)

重建后,应用程序在任务管理器中按预期显示:

在此输入图像描述