2016-01-12 44 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 –

相關問題