C# FileOpenPicker windows 10 Mobile

C# FileOpenPicker windows 10 Mobile,c#,uwp,filepicker,C#,Uwp,Filepicker,我想做一个uwp应用程序,我想使用FileOpenPicker,但该应用程序只能在windows 10上运行,不能在windows 10 mobile上运行 在windows 10 mobile上,我的应用程序崩溃…异常消息为:“未找到元素。(HRESULT中的异常:0x80070490)” 这是我的代码: FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerV

我想做一个uwp应用程序,我想使用FileOpenPicker,但该应用程序只能在windows 10上运行,不能在windows 10 mobile上运行

在windows 10 mobile上,我的应用程序崩溃…异常消息为:“未找到元素。(HRESULT中的异常:0x80070490)”

这是我的代码:

        FileOpenPicker openPicker = new FileOpenPicker();
        openPicker.ViewMode = PickerViewMode.Thumbnail;
        openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
        openPicker.FileTypeFilter.Add(".jpg");
        openPicker.FileTypeFilter.Add(".jpeg");
        openPicker.FileTypeFilter.Add(".png");

        StorageFile file = await openPicker.PickSingleFileAsync();

        if (file != null)

        {

            var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

            var image = new BitmapImage();

            ImageBrush ib = new ImageBrush();
            ib.ImageSource = image;

            image.SetSource(stream);

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            var filePath = file.Path;
            localSettings.Values["monimage"] = filePath;

            set.Background = new ImageBrush { ImageSource = image, Stretch = Stretch.UniformToFill };

        }

        else

        {

            //

        }
我已在windows 10 mobile 10.0.14393.693上测试了我的应用程序
我没有可能在其他windows 10 mobile版本上测试,但我认为问题不在于windows 10版本,而在于我的代码…

我自己解决了问题,我测试了商店中使用FileOpenPicker的其他应用程序,它们都有相同的错误,因此我重新安装了windows 10 mobile,现在一切正常:)

请具体说明什么不起作用。我的应用程序崩溃了,但visual studio没有提供有关错误的信息……请提供更多信息,因为我已经运行了您的代码,效果很好。Lumia 930,OS 14965这是你项目中唯一的代码吗?您在生命周期事件中是否有类似EnteringBackground或其他事件?可能例外情况不符合这些行。也无法重现您的问题。您发布的代码在我的Lumia 640操作系统构建10.0.14393.693上运行良好。我还认为这里的问题不在于你发布的代码。您可以创建一个新的空白项目,用
FileOpenPicker
进行测试,应该没有错误。