Package.appxmanifest Capabilites添加条目失败

时间:2019-03-19 00:59:23

标签: visual-studio uwp windows-10

我在UWP项目中使用了broadFileSystemAccess功能。这个项目是在去年初开发的,并通过大量成功的测试案例进行了彻底调试。从那时起就没有使用过。现在,将其集成到更大的产品中时,相同的代码将失败。自那时以来,版本控制未显示任何更改。

失败的功能添加是: <rescap:Capability Name="broadFileSystemAccess"/>

Package.appxmanifest文件显示错误,表明该行是无效的子元素。

程序执行失败,并显示UnauthorizedAccessException

这是失败的软件包清单:

<?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:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
  IgnorableNamespaces="uap mp rescap">

  <Identity
    Name="2eff3ebf-1a30-4bcd-8f77-d10f54e5ec80"
    Publisher="CN=JAlden"
    Version="1.0.0.0" />

  <mp:PhoneIdentity PhoneProductId="2eff3ebf-1a30-4bcd-8f77-d10f54e5ec80" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

  <Properties>
    <DisplayName>CodeGenerator</DisplayName>
    <PublisherDisplayName>JAlden</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="CodeGenerator.App">
      <uap:VisualElements
        DisplayName="CodeGenerator"
        Square150x150Logo="Assets\Square150x150Logo.png"
        Square44x44Logo="Assets\Square44x44Logo.png"
        Description="CodeGenerator"
        BackgroundColor="transparent">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
        <uap:SplashScreen Image="Assets\SplashScreen.png" />
      </uap:VisualElements>
    </Application>
  </Applications>

  <Capabilities>
    <Capability Name="internetClient" />
    <rescap:Capability Name="broadFileSystemAccess"/>
  </Capabilities>
</Package>

此外,此应用程序是为企业而不是应用程序商店开发的,并且将被侧面加载。

1 个答案:

答案 0 :(得分:0)

正如magicandre1981所说,build 17134引入了broadFileSystemAccess功能,因此您需要确保您的项目符合要求。

然后,您需要检查“设置->隐私->文件系统” ,以查看您的应用是否可以访问文件系统。

enter image description here

实际上,文档File access permissions也提到了这一点。

  

这是受限制的功能。可在“设置”>“隐私”>“文件系统”中配置访问权限。由于用户可以随时在“设置”中授予或拒绝权限,因此您应确保您的应用对这些更改具有弹性。如果您发现您的应用无权访问,则可以选择提供Windows 10 file system access and privacy文章的链接来提示用户更改设置。请注意,用户必须关闭应用程序,切换设置,然后重新启动应用程序。如果他们在应用程序运行时切换设置,平台将暂停您的应用程序,以便您可以保存状态,然后强行终止应用程序以应用新设置。在2018年4月更新中,权限的默认值为``开''。在2018年10月更新中,默认值为“关闭”。