2014-09-19 72 views
0

我做了Windows應用商店的應用程序。它工作正常,直到我升級我的操作系統到Windows 8.1。我嘗試使用FileOpenPicker時發生錯誤:Windows 8.1 FileOpenPicker

找不到元素。 (ИсключениеизHRESULT:0x80070490)

這裏是堆棧跟蹤:

在Windows.Storage.Pickers.FileOpenPicker.PickSingleFileAsync()
在Crypto.Engine.d__13.MoveNext()

和代碼:

FileOpenPicker fop = new FileOpenPicker(); 
    fop.FileTypeFilter.Add(".jpg");//extension); 
    fop.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; 
    try 
    { 
     StorageFile file = await fop.PickSingleFileAsync(); 
     return file; 
    } 
     catch(Exception ex) {} 

哪有我修復它?

+0

我想我的項目到另一臺機器。它有錯誤。 我也創建在Visual Studio 2013的新項目和FileOpenPicker類在這裏有不同的屬性在Visual Studio 2012 2012: [激活的(100794368) [繆斯(版本= 100794368) [版本(100794368)] 和2013: [可活化的(100794368)] [木塞(版本= 100794368)] [在supportedon(100794368,Platform.Windows)] [在supportedon(100794368,Platform.WindowsPhone)] [版本(100794368)] 。 它可能是錯誤的原因?我該如何解決它? – 2014-10-19 17:40:05

回答

0

我遇到同樣的問題,並通過將代碼在正確的線程解決:

CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
    CoreDispatcherPriority::High, 
    ref new DispatchedHandler([]() 
{ 
    // **ATTANTION**: direct call `PickSingleFileAsync` in render loop will crash 
    //http://sertacozercan.com/2013/10/fixing-element-not-found-exception-from-hresult-0x80070490-error-in-windows-8-x/ 
    FileOpenPicker^ openPicker = ref new FileOpenPicker(); 
    openPicker->ViewMode = PickerViewMode::Thumbnail; 
    openPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary; 
    openPicker->FileTypeFilter->Append(".png"); 
    openPicker->FileTypeFilter->Append(".jpg"); 
    openPicker->FileTypeFilter->Append(".jpeg"); 

    auto task = openPicker->PickSingleFileAsync(); 
}