0

I have run into an Interesting scenario. Its also present here by someone on msdn forums

When I launch my application, if I lock the screen or if a call comes at that time and on resume after unlocking or disconnecting the call in respective scenarios, the application crashes throwing 0x8000ffff error. This I have observed also happens when an emailcomposetask is open from my application.

Previously I thought that it was because I was not handling Obscured and Unobscured. But now that I am handling them, still I am receiving the same case. I have observed that many other applications also crash but there are some applications like Facebook and Twitter which are able to handle it. Has any one faced this same situation? Can you please provide me a fix for this?

Am I doing anything wrong?

also note that I have changed my default loading page. Its not mainPage.xaml but xyz.xaml, where I am checking for tokens and redirecting user to mainPage automatically without any button click.

Edit : Added StackTrace

at Microsoft.Phone.Execution.NativeEmInterop.NotifyFullObscurityChanged(Boolean isObscured)
at Microsoft.Phone.Shell.PhoneApplicationService.OnFullObscurityChanged(Object sender, LockStateChangeEventArgs e)
at Microsoft.Phone.Shell.Interop.ShellPageManager.ShellPageCallback_OnLockStateChange(Object source, LockStateChangeEventArgs e)
at Microsoft.Phone.Shell.Interop.ShellPageCallback.FireOnLockStateChange(Boolean fLocked)`
Milan Aggarwal
  • 5,104
  • 3
  • 25
  • 54

1 Answers1

0

This mainly happens because of the code in OnNavigatedTo() and Page_Loaded() event handlers. Place break points and check for the issues in those two methods.

When an app is resumed in the cases you mentioned, these two methods are called in the same order.

Hope this solves your problem.

Update based on your comments:

There you are. You are clearing the entire Navigation history, and hence it dont know where to go now(even the current page is removed).

My suggestion is, Move your back history removal code from OnNavigated to the Page_Loaded event.

nkchandra
  • 5,585
  • 2
  • 30
  • 45
  • So you are using OnNavigated right. Hence problem might be with the code in it. I said problem occurs because of any of those two methods. – nkchandra Sep 18 '12 at 04:19
  • Silly of me. Sorry I just saw the wrong file. I am using both functions to correct myself. OnnavigatedTo is activated first and then Loaded function in sequence. – Milan Aggarwal Sep 18 '12 at 04:20
  • After `base.OnNavigatedTo(e);` the program terminates itself without giving any error or exception. :( I am only clearing my backstack in the OnNavigatedTo function – Milan Aggarwal Sep 18 '12 at 04:21
  • I have done what you suggested. Will test for a while and let you know the progress. Thanks :) – Milan Aggarwal Sep 18 '12 at 04:49
  • Didn't help. Still getting that error with the same call stack. Now I don't have an OnNavigatedTo function, only Loaded function is there. :( – Milan Aggarwal Sep 18 '12 at 04:51
  • inside the Page_Loaded function add the line to remove the page_loaded event. this.Loaded -= Page_Loaded; – nkchandra Sep 18 '12 at 06:11
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16814/discussion-between-nkchandra-and-milan-aggarwal) – nkchandra Sep 18 '12 at 07:50