Saw a weird problem today – an app would break when navigating to a certain page if it was not running under the debugger. Then I found it was actually navigating forward out of the application and to the Windows Phone home screen and if you tapped the back button – it would return back to the application. I first thought it had something to do with the WebBrowser control that was used inside of it and the fact that the page control was defined in a class library and not the application assembly, but it turned out to be a dead end. Well, what it did turn out is what the post title says – a UserControl was used instead of a PhoneApplicationPage. A navigation request to that control worked, but unless the app was running with a debugger attached – after a few seconds after navigating to that control it would navigate out of the app. After switching it back to be a PhoneApplicationPage – everything just started working!
It reminded me of another common problem with a stack overflow exception just killing an app with no feedback to the user, even when running under the debugger. A StackOverflowException exists, but can’t be caught – an app just immediately exits when it occurs, so be warned! 🙂