1

I ran into bizarre problem, hopefully you will be able to give me a hand. I start PhotoChooserTask, choose photo and when it comes back it suddenly throws an exception. Picture below depicts the situation. If I delete code connected with State or change writing object to string it works as expected. I try to find a solution why this error occurs. I'm receiving an error "rootframe_navigation_failed" and "An unhandled exception of type 'System.Runtime.Serialization.InvalidDataContractException' occurred in Microsoft.Phone.Interop.ni.dll". When PhotoChoser is invoked onNavigatedFrom is launched and then it stops, but why? Image assigning seems to be correct.

enter image description here

Unfortunately that has nothing in common with Image. I made simple class as I could and error still takes place but when I get rid of photochooser task and for instance put into gallery method navigation to another page there is no problem so I presume that problem results from photochoosertask. But why this happens, still trying to find out.

public partial class Page1 : PhoneApplicationPage
{
    private PhotoChooserTask photo_chooser;

    public Page1()
    {
        InitializeComponent();


    }

    private void gallery(object sender, RoutedEventArgs e)
    {
         photo_chooser = new PhotoChooserTask();
         photo_chooser.Show();
         photo_chooser.Completed += photo_chooser_Completed;
    }


    void photo_chooser_Completed(object sender, PhotoResult e)
    {
        switch (e.TaskResult)
        {
            case TaskResult.OK:
                {
                    break;
                }
        }
    }


    protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
    {
        PhoneApplicationService.Current.State["sth"] = new Rect();
        base.OnNavigatingFrom(e);
    }

}

Maximus
  • 3,458
  • 3
  • 16
  • 27
  • Cool photo but where is the error? You need to post the exception otherwise how can we start to debug this – DotNetRussell Jan 20 '14 at 20:22
  • 1
    There's something in you page that cannot get serialized while the photochoosertask launches which deactivates your app. The exception has all the information you need. Possibly the BitmapImage cannot get serialized. See http://stackoverflow.com/questions/4308777/wpf-bitmapimage-serialization-deserialization – Pantelis Jan 20 '14 at 21:31
  • Thanks for effort. I will look into this. – Maximus Jan 20 '14 at 21:50

0 Answers0