/// <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(); } }
public void Send(Exception exception) { try { var captureScreenshot = new CaptureScreenshot(); captureScreenshot.CaptureScreenToFile(string.Format("{0}\\{1}CrashScreenshot.png", Path.GetTempPath(), System.Reflection.Assembly.GetEntryAssembly().GetName().Name), ImageFormat.Png); } catch { } if (String.IsNullOrEmpty(ToEmail)) { return; } var toAddress = new MailAddress(ToEmail); var crashReport = new CrashReport(exception, toAddress); crashReport.ShowDialog(); }
private static void ShowUI(object reportCrash) { var crashReport = new CrashReport((ReportCrash) reportCrash); crashReport.ShowDialog(); }
private static void ShowUI(object reportCrash) { var crashReport = new CrashReport((ReportCrash)reportCrash); crashReport.ShowDialog(); }