- Notifications
You must be signed in to change notification settings - Fork74
Send crash reports of your classic desktop application developed using .NET Framework directly to your mail's inbox with full exception report, stack trace and screenshot.
License
ravibpatel/CrashReporter.NET
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Send crash reports of your classic desktop application developed using .NET Framework directly to your mail's inbox with full exception report, stack trace and screenshot.
PM>Install-Package CrashReporter.NET.Official
CrashReporter.NET uses the exception information like stack trace, exception type, message, source, .NET CLR version, OS version and application version to generate the crash report and send it to developer using email. It usesDoctorDump service to send email to developer. Developers can use their SMTP server to send email too.
First thing you need to do is subscribe to Application.ThreadException and AppDomain.CurrentDomain.UnhandledException in your Program.cs file as shown below.
staticclassProgram{privatestaticReportCrash_reportCrash;/// <summary>/// The main entry point for the application./// </summary>[STAThread]staticvoidMain(){Application.ThreadException+=(sender,args)=>SendReport(args.Exception);AppDomain.CurrentDomain.UnhandledException+=(sender,args)=>{SendReport((Exception)args.ExceptionObject);};Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);_reportCrash=newReportCrash("Email where you want to receive crash reports"){Silent=true,ShowScreenshotTab=true,IncludeScreenshot=false, #region Optional ConfigurationWebProxy=newWebProxy("Web proxy address, if needed"),AnalyzeWithDoctorDump=true,DoctorDumpSettings=newDoctorDumpSettings{ApplicationID=newGuid("Application ID you received from DrDump.com"),OpenReportInBrowser=true} #endregion};_reportCrash.RetryFailedReports();Application.Run(newFormMain());}publicstaticvoidSendReport(Exceptionexception,stringdeveloperMessage=""){_reportCrash.DeveloperMessage=developerMessage;_reportCrash.Silent=false;_reportCrash.Send(exception);}publicstaticvoidSendReportSilently(Exceptionexception,stringdeveloperMessage=""){_reportCrash.DeveloperMessage=developerMessage;_reportCrash.Silent=true;_reportCrash.Send(exception);}}
Just set the ToEmail in above example with your email to start receiving crash reports.
If you want to handle exception report for individual exception with special message you can do it like shown below.
conststringpath="test.txt";try{if(!File.Exists(path)){thrownewFileNotFoundException("File Not found when trying to write argument exception to the file",argumentException);}}catch(Exceptionexception){Program.SendReport(exception,"Value of path variable is "+path);}
First thing you need to do is subscribe to AppDomain.CurrentDomain.UnhandledException in your App.xaml.cs file as shown below.
publicpartialclassApp:Application{privatestaticReportCrash_reportCrash;protectedoverridevoidOnStartup(StartupEventArgse){base.OnStartup(e);AppDomain.CurrentDomain.UnhandledException+=CurrentDomainOnUnhandledException;Application.Current.DispatcherUnhandledException+=DispatcherOnUnhandledException;TaskScheduler.UnobservedTaskException+=TaskSchedulerOnUnobservedTaskException;_reportCrash=newReportCrash("Email where you want to receive crash reports"){Silent=true};_reportCrash.RetryFailedReports();}privatevoidTaskSchedulerOnUnobservedTaskException(objectsender,UnobservedTaskExceptionEventArgsunobservedTaskExceptionEventArgs){SendReport(unobservedTaskExceptionEventArgs.Exception);}privatevoidDispatcherOnUnhandledException(objectsender,DispatcherUnhandledExceptionEventArgsdispatcherUnhandledExceptionEventArgs){SendReport(dispatcherUnhandledExceptionEventArgs.Exception);}privatestaticvoidCurrentDomainOnUnhandledException(objectsender,UnhandledExceptionEventArgsunhandledExceptionEventArgs){SendReport((Exception)unhandledExceptionEventArgs.ExceptionObject);}publicstaticvoidSendReport(Exceptionexception,stringdeveloperMessage=""){_reportCrash.Silent=false;_reportCrash.Send(exception);}publicstaticvoidSendReportSilently(Exceptionexception,stringdeveloperMessage=""){_reportCrash.Silent=true;_reportCrash.Send(exception);}}
Just set the ToEmail in above example with your email to start receiving crash reports.
If you want to handle exception report for individual exception with special message you can do it like shown below.
conststringpath="test.txt";try{if(!File.Exists(path)){thrownewFileNotFoundException("File Not found when trying to write argument exception to the file",argumentException);}}catch(Exceptionexception){App.SendReport(exception,"Value of path variable is "+path);}
You can show screenshot tab by setting ShowScreenshotTab to true. It will be false by default.
reportCrash.ShowScreenshotTab=true
You can set the IncludeScreenshot value to false if you don't want to include screenshot in the crash report. If you are showing the screenshot tab then user can still choose to include the screenshot even if you set it to false.
reportCrash.IncludeScreenshot=false;
You can send crash reports silently by setting Silent property to true.
reportCrash.Silent=true;
You can send crash report using a web proxy by adding following line in SendReport method.
reportCrash.WebProxy=newWebProxy("Web proxy address"),
You can send crash report to you doctor dump account by adding following line in SendReport method.
reportCrash.DoctorDumpSettings=newDoctorDumpSettings{ApplicationID=newGuid("Application ID you received from DrDump.com"),};
Just set the ApplicationID to ID you received from DrDump.com.
You can take screenshot of whole screen instead of only application when application crashes by adding following line in SendReport method.
reportCrash.CaptureScreen=true;
You can use the SMTP server instead of DrDump service to send crash reports as shown below.
varreportCrash=newReportCrash{AnalyzeWithDoctorDump=false,SmtpHost="smtp.gmail.com",Port=587,EnableSSL=true,UserName="Your Gmail account email",Password="Your Gmail account password",ToEmail="Email address where you want receive crash reports",FromEmail="Your Gmail account email or alias"};
About
Send crash reports of your classic desktop application developed using .NET Framework directly to your mail's inbox with full exception report, stack trace and screenshot.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors12
Uh oh!
There was an error while loading.Please reload this page.