static SdeErrorHandler() { if (Configuration.EnableDebuggerTrace) { if (_debugDialog == null) _debugDialog = new DebuggerDialog(); if (!_debugDialog.IsLoaded) _debugDialog.Show(); if (!_debugDialog.IsVisible) { _debugDialog.Visibility = Visibility.Visible; } } }
private void _backgroundWindowOwnership() { while (_backgroundThreadRunning) { try { Thread.Sleep(700); if (!Configuration.EnableDebuggerTrace) continue; Application.Current.Dispatcher.Invoke(new Action(delegate { if (_enableClosing || Application.Current.MainWindow == null) return; foreach (Window window in Application.Current.MainWindow.OwnedWindows) { if (window is ErrorDialog) { if (((ErrorDialog)window).ErrorLevel == ErrorLevel.NotSpecified) return; _enableClosing = true; DebuggerDialog dialog = new DebuggerDialog(false); Visibility = Visibility.Hidden; dialog.Width = Width; dialog.Height = Height; dialog.Left = Left; dialog.Top = Top; window.Closed += delegate { Width = dialog.Width; Height = dialog.Height; Left = dialog.Left; Top = dialog.Top; dialog.Close(); Visibility = Visibility.Visible; _enableClosing = false; Application.Current.Dispatcher.Invoke(new Action(delegate { Application.Current.MainWindow.Activate(); Application.Current.MainWindow.Topmost = true; Application.Current.MainWindow.Topmost = false; Application.Current.MainWindow.Focus(); })); }; dialog.Update(_recentDebugInfo); dialog.Show(); } } })); } catch (Exception err) { MessageBox.Show(err.Message); } } }
private void _backgroundWindowOwnership() { while (_backgroundThreadRunning) { try { Thread.Sleep(700); if (!Configuration.EnableDebuggerTrace) { continue; } Application.Current.Dispatcher.Invoke(new Action(delegate { if (_enableClosing || Application.Current.MainWindow == null) { return; } foreach (Window window in Application.Current.MainWindow.OwnedWindows) { if (window is ErrorDialog) { if (((ErrorDialog)window).ErrorLevel == ErrorLevel.NotSpecified) { return; } _enableClosing = true; DebuggerDialog dialog = new DebuggerDialog(false); Visibility = Visibility.Hidden; dialog.Width = Width; dialog.Height = Height; dialog.Left = Left; dialog.Top = Top; window.Closed += delegate { Width = dialog.Width; Height = dialog.Height; Left = dialog.Left; Top = dialog.Top; dialog.Close(); Visibility = Visibility.Visible; _enableClosing = false; Application.Current.Dispatcher.Invoke(new Action(delegate { Application.Current.MainWindow.Activate(); Application.Current.MainWindow.Topmost = true; Application.Current.MainWindow.Topmost = false; Application.Current.MainWindow.Focus(); })); }; dialog.Update(_recentDebugInfo); dialog.Show(); } } })); } catch (Exception err) { MessageBox.Show(err.Message); } } }
private void _reportAnyManagedExceptions(string message, Exception exception, ErrorLevel errorLevel) { if (Configuration.LogAnyExceptions) { try { string crash = "\r\n\r\n\r\n" + ApplicationManager.PrettyLine(DateTime.Now.ToString(CultureInfo.InvariantCulture)) + "\r\n"; try { if (exception != null) { crash += exception.ToString(); } else { StackTrace st = new StackTrace(true); crash += st.ToString(); } } catch { } try { if (exception != null) crash += "\r\n" + ApplicationManager.PrettyLine("Inner exception") + "\r\n" + exception.InnerException; } catch { } File.AppendAllText(Path.Combine(SdeAppConfiguration.ProgramDataPath, "debug.log"), crash); } catch { } } StackTrace trace = new StackTrace(true); if (Configuration.EnableDebuggerTrace) { if (_debugDialog == null) _debugDialog = new DebuggerDialog(); if (errorLevel == ErrorLevel.NotSpecified) return; _debugDialog.Dispatch(delegate { if (!_debugDialog.IsLoaded) _debugDialog.Show(); if (!_debugDialog.IsVisible) { _debugDialog.Visibility = Visibility.Visible; _debugDialog.Topmost = true; _debugDialog.Topmost = false; } _debugDialog.Update(DateTime.Now, exception, trace, message); }); } }
public static void ShowStackTraceViewer() { if (_debugDialog == null) _debugDialog = new DebuggerDialog(); _debugDialog.Dispatcher.Invoke(new Action(delegate { if (Configuration.EnableDebuggerTrace) { if (!_debugDialog.IsLoaded) _debugDialog.Show(); if (!_debugDialog.IsVisible) { _debugDialog.Visibility = Visibility.Visible; } } else { if (_debugDialog.IsLoaded) { _debugDialog.Visibility = Visibility.Hidden; } } foreach (Window window in Application.Current.Windows) { if (window.Visibility == Visibility.Visible && window.IsLoaded && window != _debugDialog) { Application.Current.MainWindow = window; } } })); }