访问Windows IoT核心应用程序中的usb棒文件时访问被拒绝错误

时间:2016-01-12 22:07:53

标签: raspberry-pi2 windows-10-iot-core windowsiot

我想使用Windows 10 IoT Core从我的Raspberry Pi 2上的USB记忆棒访问文件(图像,文本文件等)。

所以我已将其添加到appxmanifest文件中。

在我的IBackgroundTask中使用此代码时,我在第二行出现access denied错误:

public sealed class StartupTask : IBackgroundTask
{
    public async void Run(IBackgroundTaskInstance taskInstance)
    {
    //...
        Windows.Storage.StorageFolder sf = Windows.Storage.KnownFolders.RemovableDevices;
        //get list of drives
        IReadOnlyList<Windows.Storage.StorageFolder> list = await sf.GetFoldersAsync();
    ...
    }
}

我发现我应该添加fileTypeAssociation以及我想要在Package.appxmanifest中访问的文件类型,所以我这样做了:

<?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:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" IgnorableNamespaces="uap mp iot">
  <Identity Name="test-uwp" Publisher="CN=user" Version="1.0.0.0" />
  <mp:PhoneIdentity PhoneProductId="8f31dff8-3a2b-4df1-90bb-2c5267f32980" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
  <Properties>
    <DisplayName>test</DisplayName>
    <PublisherDisplayName>user</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">
      <uap:VisualElements DisplayName="test" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="test" BackgroundColor="transparent" AppListEntry="none">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
        </uap:DefaultTile>
        <uap:SplashScreen Image="Assets\SplashScreen.png" />
      </uap:VisualElements>
      <Extensions>
        <Extension Category="windows.backgroundTasks" EntryPoint="test.StartupTask">
          <BackgroundTasks>
            <iot:Task Type="startup" />
          </BackgroundTasks>
        </Extension>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap:FileTypeAssociation Name="myimages">
            <uap:SupportedFileTypes>
              <uap:FileType ContentType="image/jpeg">.jpg</uap:FileType>
            </uap:SupportedFileTypes>
          </uap:FileTypeAssociation>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
  <Capabilities>
    <Capability Name="internetClient" />
    <uap:Capability Name="removableStorage" />
  </Capabilities>
</Package>

如果我想部署它,我会收到以下错误:

  

严重级代码描述项目文件行抑制状态   错误错误:DEP0700:应用程序注册失败。   AppxManifest.xml(37,10):错误0x80070490:无法注册   test-uwp_1.0.0.0_arm__yzekw4x8qxe1g包因为以下内容   解析windows.fileTypeAssociation时遇到错误   扩展元素:未找到元素。 。再试一次,然后联系   包问题发布者,如果问题仍然存在(0x80073cf6)

一旦删除uap:Extension元素,错误就会消失(但拒绝访问仍然存在)。

我错过了什么吗?是不是可以使用后台服务从USB记忆棒访问文件(我想在没有用户交互的情况下运行无头)?

1 个答案:

答案 0 :(得分:2)

目前您无法注册使用filetypeAssociation的无头应用。 有一种解决方法 - 请参阅此处:https://github.com/ms-iot/ntvsiot/issues/62

只需将一个应用程序(项目)添加到您的解决方案中(不需要任何特殊代码)。 在无头应用程序中添加对此项目的引用。

现在更改headless(文件asso ..)的清单并添加Executable:YourHeadedApp.exe和EntryPoint:YourHeadedApp.App现在与下一次部署EXE将包含在部署中 - 因此可以在清单中找到它检查。