2014-09-19 47 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(); 
}