private static void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { try { string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); Tracer.Error(errorMsg); e.Handled = true; var control = new ExceptionControl(); var viewModel = new ExceptionViewModel(); viewModel.Exception = GenerateCrashReport(e.ExceptionObject); control.DataContext = viewModel; _gameHost.LayoutRoot.Children.Clear(); _gameHost.LayoutRoot.Children.Add(control); } catch { try { MessageBox.Show(e.ExceptionObject.ToString()); } catch { ReportErrorToDOM(e.ExceptionObject); } } }