/// <summary> /// Sends exception report directly to receiver email address provided in ToEmail. /// </summary> /// <param name="exception">Exception object that contains details of the exception.</param> public void Send(Exception exception) { Exception = exception; var mainAssembly = Assembly.GetEntryAssembly(); string appTitle = null; var attributes = mainAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true); if (attributes.Length > 0) { appTitle = ((AssemblyTitleAttribute)attributes[0]).Title; } ApplicationTitle = !string.IsNullOrEmpty(appTitle) ? appTitle : mainAssembly.GetName().Name; ApplicationVersion = mainAssembly.GetName().Version.ToString(); try { ScreenShot = $@"{Path.GetTempPath()}\{ApplicationTitle} Crash Screenshot.png"; if (CaptureScreen) { CaptureScreenshot.CaptureScreen(ScreenShot, ImageFormat.Png); } else { CaptureScreenshot.CaptureActiveWindow(ScreenShot, ImageFormat.Png); } } catch (Exception e) { Debug.Write(e.Message); } if (String.IsNullOrEmpty(ToEmail) || !AnalyzeWithDoctorDump && (String.IsNullOrEmpty(FromEmail) || String.IsNullOrEmpty(SmtpHost))) { return; } if (!Application.MessageLoop) { Application.EnableVisualStyles(); } CrashReport crashReport = new CrashReport(this); if (Thread.CurrentThread.GetApartmentState().Equals(ApartmentState.MTA)) { var thread = new Thread(() => crashReport.ShowDialog()) { IsBackground = false }; thread.CurrentCulture = thread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } else { crashReport.ShowDialog(); } }
/// <summary> /// Sends exception report directly to receiver email address provided in ToEmail. /// </summary> /// <param name="exception">Exception object that contains details of the exception.</param> public void Send(Exception exception) { Exception = exception; var mainAssembly = Assembly.GetEntryAssembly(); string appTitle = null; var attributes = mainAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true); if (attributes.Length > 0) { appTitle = ((AssemblyTitleAttribute)attributes[0]).Title; } ApplicationTitle = !string.IsNullOrEmpty(appTitle) ? appTitle : mainAssembly.GetName().Name; ApplicationVersion = mainAssembly.GetName().Version.ToString(); try { ScreenShot = string.Format(@"{0}\{1} Crash Screenshot.png", Path.GetTempPath(), ApplicationTitle); if (CaptureScreen) { CaptureScreenshot.CaptureScreen(ScreenShot, ImageFormat.Png); } else { CaptureScreenshot.CaptureActiveWindow(ScreenShot, ImageFormat.Png); } } catch (Exception e) { Debug.Write(e.Message); } if (String.IsNullOrEmpty(ToEmail) || !AnalyzeWithDoctorDump && (String.IsNullOrEmpty(FromEmail) || String.IsNullOrEmpty(SmtpHost))) { return; } var parameterizedThreadStart = new ParameterizedThreadStart(ShowUI); var thread = new Thread(parameterizedThreadStart) { IsBackground = false }; thread.CurrentCulture = thread.CurrentUICulture = CurrentCulture ?? System.Windows.Forms.Application.CurrentCulture; thread.SetApartmentState(ApartmentState.STA); thread.Start(this); thread.Join(); }
private void Send(Exception exception, bool silent) { Exception = exception; var mainAssembly = Assembly.GetEntryAssembly(); string appTitle = null; var attributes = mainAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true); if (attributes.Length > 0) { appTitle = ((AssemblyTitleAttribute)attributes[0]).Title; } ApplicationTitle = !string.IsNullOrEmpty(appTitle) ? appTitle : mainAssembly.GetName().Name; ApplicationVersion = ((Type.GetType("Mono.Runtime") == null) && ApplicationDeployment.IsNetworkDeployed) ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : mainAssembly.GetName().Version.ToString(); try { ScreenShot = $@"{Path.GetTempPath()}\{ApplicationTitle} Crash Screenshot.png"; if (CaptureScreen) { CaptureScreenshot.CaptureScreen(ScreenShot, ImageFormat.Png); } else { CaptureScreenshot.CaptureActiveWindow(ScreenShot, ImageFormat.Png); } } catch (Exception e) { Debug.Write(e.Message); } if (!AnalyzeWithDoctorDump) { if (string.IsNullOrEmpty(FromEmail)) { throw new ArgumentNullException(@"FromEmail"); } if (string.IsNullOrEmpty(SmtpHost)) { throw new ArgumentNullException("SmtpHost"); } } if (!Application.MessageLoop) { Application.EnableVisualStyles(); } if (silent) { SendReport(IncludeScreenshot); } else { if (Thread.CurrentThread.GetApartmentState().Equals(ApartmentState.MTA)) { var thread = new Thread(() => new CrashReport(this).ShowDialog()) { IsBackground = false }; thread.CurrentCulture = thread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } else { new CrashReport(this).ShowDialog(); } } }