c# - Windows 10 UWP AppService,package.appxmanifest 问题

标签 c# uwp windows-10 appxmanifest

我正在尝试按照这篇 Microsoft 文章 https://learn.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service 在 UWP 中制作一个简单的 ServiceApp

但是,本文建议的 list 更改导致我的服务应用无法构建。

enter image description here

我花了几天时间在 Microsoft 文档中搜索诸如“http://schemas.microsoft.com/appx/manifest/uap/windows10/4”、“uap4”和“SupportsMultipleInstances”之类的术语,但一直没有找到构建失败的原因。我已经在 MSDN 上发布了很多包含详细信息的问题,但这最终是浪费时间,所以,和 MS 一样。

我的 Windows 10 版本是 1703,Windows 10 企业版,操作系统内部版本 15063.413

Visual Studio 2015 企业版,版本 14.0.25431.01 更新 3

下面是我得到的错误

Validation error. error C00CE015: App manifest validation error: 
The app manifest must be valid as per schema: 
Line 31, Column 58, Note: 
The schema for OSMinVersion specified does not recognize XML fields with namespace "http://schemas.microsoft.com/appx/manifest/uap/windows10/4". 
Please ensure that you have the correct OSMinVersion specified. Reason: The attribute '{http://schemas.microsoft.com/appx/manifest/uap/windows10/4}SupportsMultipleInstances' on the element '{http://schemas.microsoft.com/appx/manifest/uap/windows10}AppService' is not defined in the DTD/Schema.   
AppServiceProviderInSeparateBackgroundProcess   C:\Users\myuid\Desktop\work\AppServiceProviderInSeparateBackgroundProcess\AppServiceProviderInSeparateBackgroundProcess\bin\x86\Debug\AppxManifest.xml  

这是由 Blank App (Universal Windows) 创建的完整 Package.appmanifest,并按照文章的建议添加了命名空间和扩展标签

<?xml version="1.0" encoding="utf-8"?>

<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
  IgnorableNamespaces="uap mp">

  <Identity
    Name="8db1ab9e-1dff-4fd4-a450-77fadd221043"
    Publisher="CN=username"
    Version="1.0.0.0" />

  <mp:PhoneIdentity PhoneProductId="8db1ab9e-1dff-4fd4-a450-77fadd221043" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

  <Properties>
    <DisplayName>AppServiceProviderInSeparateBackgroundProcess</DisplayName>
    <PublisherDisplayName>username</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>

  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
  </Dependencies>

  <Resources>
    <Resource Language="x-generate"/>
  </Resources>

  <Applications>
    <Application Id="App"
      Executable="$targetnametoken$.exe"
      EntryPoint="AppServiceProviderInSeparateBackgroundProcess.App">
      <!-- Added Appservice extension that advertises com.Microsoft.Inventory service
           This identifies this app as an app service provider.  The service wil be
           implemented as a background task.
           The app service app exposes the service to other apps.-->
      <Extensions>
        <uap:Extension Category="windows.appService" EntryPoint="MyAppService.Inventory">
          <uap:AppService Name="com.microsoft.inventory" uap4:SupportsMultipleInstances="true"/>
        </uap:Extension>
      </Extensions>
      <uap:VisualElements
        DisplayName="AppServiceProviderInSeparateBackgroundProcess"
        Square150x150Logo="Assets\Square150x150Logo.png"
        Square44x44Logo="Assets\Square44x44Logo.png"
        Description="AppServiceProviderInSeparateBackgroundProcess"
        BackgroundColor="transparent">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
        <uap:SplashScreen Image="Assets\SplashScreen.png" />
      </uap:VisualElements>
    </Application>
  </Applications>

  <Capabilities>
    <Capability Name="internetClient" />
  </Capabilities>
</Package>

版本UWP截图如下 enter image description here

enter image description here

Windows 10 开发工具包 enter image description here

最佳答案

问题是您需要使用 Visual Studio 2017 和目标版本 15063 或更高版本才能使用 uap4-namespaced 属性。

关于c# - Windows 10 UWP AppService,package.appxmanifest 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45173965/

相关文章:

c# - 通过绑定(bind)设置文本时,文本框删除按钮(小 x)不可见

c# - Toast 不显示

node.js - NPM:在具有nvm的Windows 10上运行npm -v时找不到npm-cli.js

c# - Windows 7 计算器破坏 WPF 多点触控?

c# - 如何在运行时动态地将值传递给 ObjectDataProvider.MethodParameters

c# - 如何在 CurrentEnv 为 Prod 时忽略 C# 中的测试

c# - 如何从 Bing Maps API 获取交通数据?

javascript - 更改 Appxmanifest 中的设置以实现不同的解决方案配置(UWP 项目)

c# - 表格未显示在 Visual Studio 2012 中

c - C 中循环控制台菜单实现的问题