I created an error Logging for my WP8 Application so that whenever the application crashes, a MessageBox will show and will ask the user to send the Log File through email.
This is how I implemented it in App.xaml.cs,
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
//File Handler for Log file
Log.write("some string here");
MessageBoxResult result = MessageBox.Show("String", "String", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK) // BREAKPOINT here
{
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "Unhandled Exception";
emailComposeTask.Body = "Device OS Version: " + Environment.OSVersion.ToString() + "\n\n" + Log.readFile();
emailComposeTask.To = "email@email.com";
emailComposeTask.Show();
}
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}
During debug in my device, everything works fine and was able to send the Log content to my email IF I PUT A BREAKPOINT in if (result == MessageBoxResult.OK)
or any line before emailComposeTask.Show();
And if I disable the breakpoint, MessageBox shows BUT emailComposeTask
won't show.
What could be the problem? Only during debug and breakpointing it works, not when I remove the breakpoint.