0

I made the app for windows store. It worked fine until I upgraded my os to Windows 8.1. There is an error while I'm trying to FileOpenPicker:

Element not found. (Исключение из HRESULT: 0x80070490)

Here is stacktrace:

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

and code:

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

How can I fix it?

  • I tried my project to another machine. And it had the error to. Also I create new project in Visual Studio 2013 and FileOpenPicker class has different attributes here as in Visual Studio 2012. 2012: [Activatable(100794368)] [Muse(Version = 100794368)] [Version(100794368)] and 2013: [Activatable(100794368)] [Muse(Version = 100794368)] [SupportedOn(100794368, Platform.Windows)] [SupportedOn(100794368, Platform.WindowsPhone)] [Version(100794368)]. Can it be a reason of the error? How can I fix it? – Daria Korosteleva Oct 19 '14 at 17:40

1 Answers1

0

I encountered the same problem and solved by putting code in the right thread:

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();
}
Kanglai
  • 530
  • 1
  • 6
  • 18