Windows 8 Windows 8.1文件OpenPicker
我为windows应用商店制作了应用程序。在我将操作系统升级到Windows8.1之前,它工作得很好。尝试使用FileOpenPicker时出错: 未找到元素。结果:0x80070490 这里是stacktrace: 在Windows.Storage.Pickers.FileOpenPicker.PickSingleFileAsync 在Crypto.Engine.d_u13.MoveNext 和代码:Windows 8 Windows 8.1文件OpenPicker,windows-8,windows-8.1,fileopenpicker,Windows 8,Windows 8.1,Fileopenpicker,我为windows应用商店制作了应用程序。在我将操作系统升级到Windows8.1之前,它工作得很好。尝试使用FileOpenPicker时出错: 未找到元素。结果:0x80070490 这里是stacktrace: 在Windows.Storage.Pickers.FileOpenPicker.PickSingleFileAsync 在Crypto.Engine.d_u13.MoveNext 和代码: FileOpenPicker fop = new FileOpenPicker();
FileOpenPicker fop = new FileOpenPicker();
fop.FileTypeFilter.Add(".jpg");//extension);
fop.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
try
{
StorageFile file = await fop.PickSingleFileAsync();
return file;
}
catch(Exception ex) {}
如何修复它?我遇到了同样的问题,通过将代码放入正确的线程解决了这个问题:
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();
}
我尝试将我的项目转移到另一台机器上。它有一个错误。我还在Visual Studio 2013中创建了新项目,FileOpenPicker类在这里具有与Visual Studio 2012中不同的属性。2012:[Activatable100794368][MuseVersion=100794368][Version100794368]和2013:[Activatable100794368][MuseVersion=100794368][SupportedOn100794368,Platform.Windows][SupportedOn100794368,Platform.WindowsPhone][Version100794368]。这可能是错误的原因吗?我怎样才能修好它?