The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
App crashes after tombstone restore RRS feed

  • General discussion

  • I'm having problems with my app crashing after it has been tombstoned and restored. It is a simple newsreader/webviewing app.

    When I tombstone from an article page I store my page data in the State, and when the app is restored the page displays again fine.
    When I navigate back from this the main page displays fine again, but when I select a new article, talking me back into the detail page the app calls my OnNavigatedTo function, runs through it without any errors, but then crashes me out back to the start screen, terminating my debug session, but with no errors.

    Here is my OnNavigatedTo function:

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
            { 
     
                if (State.ContainsKey("newPage")) 
                { 
                    newPage = (bool)State["newPage"]; 
                    if (!newPage) 
                    { 
                        sRssItem = (string)State["sRssItem"]; 
                        link = (Uri)State["link"]; 
                        PageTitle.Text = (string)State["title"]; 
                    } 
                } 
                if (link == null
                { 
                    link = new Uri(((RSSItem)DataContext).Link); 
                } 
     
                WebClient client = new WebClient(); 
                client.DownloadStringAsync(link); 
                client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(c_DownloadStringCompleted); 
                base.OnNavigatedTo(e); 
            } 


    After stepping through this function and reaching the end it crashes. Could anyone help, or atleast point me to where the app goes immediately after OnNavigatedTo()? I also have a breakpoint on my DownloadStringCompleted() function, but it never reaches there when it crashes.
    Sunday, August 7, 2011 4:34 PM

All replies

  • I think you want to move the last line of code, base.OnNavigatedTo(e);, to be the first line of code.
    Sunday, August 7, 2011 5:14 PM
  • Thanks for the suggestion.

    I changed it but the issue still remains.

    Strangely though I cannot recreate the issue when deployed to my device, but it happens in the emulator every time. Could it be an emulator issue rather than a coding? I don't want to go submitting an app if it is only going to be rejected because of this, but I also don't want to delay submitting it trying to resolve a non-issue.


    Sunday, August 7, 2011 5:25 PM
  • Have you tried setting a breakpoint on the section in your event handler "c_DownloadStringCompleted"?

    Also, think the subscription to the DownloadStringCompleted event should be done before you call the DownloadStringAsync method.

    So switch order to:
    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(c_DownloadStringCompleted);
    client.DownloadStringAsync(link); 

    Tuesday, August 9, 2011 8:31 PM