2016-01-12 22 views
3

我想使用Windows 10 IoT Core从我的Raspberry Pi 2上的U盘访问文件(图像,文本文件等)。在Windows IoT核心应用程序中访问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> 

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

Severity Code Description Project File Line Suppression State Error Error : DEP0700 : Registration of the app failed. AppxManifest.xml(37,10): error 0x80070490: Cannot register the test-uwp_1.0.0.0_arm__yzekw4x8qxe1g package because the following error was encountered while parsing the windows.fileTypeAssociation Extension element: Element not found. . Try again and contact the package publisher if the problem persists. (0x80073cf6)

只要我删除uap:Extension元素,错误消失(但拒绝访问仍然存在)。

我错过了什么?是否无法使用后台服务从USB存储器访问文件(我想在没有用户交互的情况下运行该无人机)?

+0

这里对我来说同样的问题。找不到任何信息,为什么这不起作用。清单编辑器让我添加关联,但... – ManniAT

回答

0

已经在您的“普通”Windows 10开发机器上测试过该应用程序了吗?那里有错误吗?

2

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

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

现在更改无头文件(文件asso ..),并添加可执行文件:YourHeadedApp.exe和EntryPoint:YourHeadedApp.App现在与下一个部署EXE将包含在部署 - 所以它可以被发现时清单被检查。

+0

后台任务(无头应用程序)可以调用并打开头部应用程序吗? – Jnr

+0

为我工作,谢谢。 munyirik提供的完整appxmanifest(https://github.com/ms-iot/ntvsiot/issues/62#issuecomment-263392332)也非常有用:https://github.com/ms-iot/ ntvsiot /文件/ 617448/Package.appxmanifest.txt –

相关问题