1

Recently I am writing an app on My PC and lumia 640, everything seems good when it runs under Debug mode in VS 2015, but when I use it on my phone and tap a button to open a FileOpenPicker to choose picture from PicturesLibrary, it just crash...

When I try connecting my phone and use VS to find the problem, it never shows up any more...Also, when I run my app on my PC, whether under Debug mode or not, the problem also never happens.

The Listener of the button looks like this:

private async void OnSnap(object sender, RoutedEventArgs e)
        {
            try
            {
                FileOpenPicker fileOpenPicker = new FileOpenPicker();
                fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                fileOpenPicker.FileTypeFilter.Add(".jpg");
                fileOpenPicker.FileTypeFilter.Add(".png");
                fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
            
                var inputFile = await fileOpenPicker.PickSingleFileAsync();
                if (inputFile == null)
                {
                    // The user cancelled the picking operation
                    return;
                }
                else
                {
                    Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(inputFile);
                    Frame frame = Window.Current.Content as Frame;
                    frame.Navigate(typeof(PictureChoosePage), await inputFile.OpenAsync(FileAccessMode.Read));
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);

                var msgDialog = new MessageDialog(exception.Message) { Title = "Unkown Error" };
                msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("OK", uiCommand => {
                    Frame frame = Window.Current.Content as Frame;
                    frame.Navigate(typeof(MainPage));
                }));
                msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("Cancel", uiCommand => { }));
                await msgDialog.ShowAsync();

                return;
            }
        }

One more thing to mention is that when my App crash, the bottom bar of the FileOpenPicker shows up...like this: Click to view it

The required permissions should have been declared, and if there is a UnathorizedAccessException thrown, it should be caught by my code...So I'm thinking if this is the bug of the OS since the windows 10 mobile on my lumia 640 is 10.0.14295.1000, just a preview version.

Sissel Wu
  • 11
  • 3
  • 1. Please post the source code by text, not an image... 2. Please change the language from Chinese to English... 3. Please use the screenshot from the mobile, not a photo... – Sayakiss Apr 23 '16 at 04:30
  • Have you [checked how your *Suspending* and *Resuming* events run](http://stackoverflow.com/a/24103734/2681948)? – Romasz Apr 23 '16 at 04:42

0 Answers0