how to debug app in windows phone 7 that is not launched from visual studios
i am currently working on handling tombstoning for my app. to tombstone my app, i navigate 2 pages into my app (from the first page). i then hit the home button, then i hit the back button to get back to my app. after hitting the back button, all i see is a page that says "resuming" with a progress bar. it just seems to stall.
now, when i launch the app, i launch it from visual studio to my device. but as soon as i hit the home button on the device, the debugger in visual studio quits. so when i hit the back button to get to my app, i don't get a chance to debug from visual studio any more.
is there a setting i need to set so that hitting the home button doesn't stop debugging?
also, if i try to go to my app on my device through the app listing, my app stalls with the default splash screen image. so something is definitely going wrong.
is there a process associated with the device that i can attach the debugger in visual studio to for debugging? or do i always need to launch the application from visual studio to debug?
a sample code of how i handle tombstoning is as follows.
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
if(NavigationMode.Back != e.Naviga开发者_JS百科tionMode)
{
try
{
PhoneApplicationService.Current.State["token"] = myMvvM;
}
catch(Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
}
right now i don't do anything on Application_UnhandledException in App.xaml.cs. the code is left as generated (i only but Debug.WriteLine in there to view the log).
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
//break point is placed on line right below this comment line
Debug.WriteLine("unhandled exception sender type = " +
sender.GetType().FullName + ", ex = " + e.ToString());
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
If you're running in debug mode, it won't quit when you click home, unless a exception occurs. It'll only quit if you exit the application, ie. press back from the first screen.
But it sounds like your tombstoning logic is throwing a exception, and you're not catching it. Have you implemented a handler for the Application.UnhandledException event? (The default App.xaml.cs templates for Visual Studio implements it)
精彩评论