Click here to Skip to main content
12,821,084 members (32,724 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


53 bookmarked
Posted 21 Apr 2009

Little Crash Reporter

, 29 Apr 2009 GPL3
Rate this:
Please Sign up or sign in to vote.
Collect crash data from a machine and send it to your email to be analyzed.


Normally, when an exception occurs in .NET, the exception details are shown and the application either continues or fails. This source code allows you to collect the necessary information and send it to an SMTP server so that it will arrive in your mailbox.

Unhandled Exceptions

For example, take the following divide by zero exception that can occur in a .NET program.

int i = 0;
int j = 1 / i;

Once this exception is thrown, .NET will first see if there is anything that is trying to catch the exception, otherwise the following dialog will appear.

The end user can then either continue to execute the requested function or quit the application.

This is what it will look like if an exception occurs in a program with LCR built in

How Little Crash Reporter Works

The picture below shows how an error that occurs in your program is generated and sent to you

This is the class diagram of the program. The main functions used are the event handlers (Application_ThreadException and CurrentDomain_UnhandledException) that send a signal once there is an exception. After that, LCR takes it over from there...

How Little Crash Reporter Is Used

Before the crash reporter can work, the event handlers must be set to detect when an exception occurs.

// Add event handler for thread exceptions
Application.ThreadException += 
  new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += 
  new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

And dont forget...

// Event handler functions
static void CurrentDomain_UnhandledException(object sender, 
            UnhandledExceptionEventArgs e)
    CrashReporter ErrorDlg = new CrashReporter((Exception)e.ExceptionObject);

static void Application_ThreadException(object sender, 
       System.Threading.ThreadExceptionEventArgs e)
    CrashReporter ErrorDlg = new CrashReporter(e.Exception);

Even though the event args specifies just a normal exception object being sent, the actual exception is retrieved via typeof.

Next we need to configure the URL for the PHP script and the error directory (normally just leave it).

private readonly string BugReportURI = "";
private readonly string ErrorDirectory = string.Format(@"{0}\Errors", 

Once that's finished, use the files in the PHP Uploader folder to configure the SMTP server, username and password for the emails. Then upload them to the web server you specified.

$host = "";
$username = "smtp_username";
$password = "smtp_password";

To test it out, create a divide by zero exception.

int i = 0;
int j = 1 / i;

Your program should now be ready to send bug reports.

Points of Interest

If you are looking for somewhere to upload files and send them to a secure SMTP server, just search Google for a free web host that has cPanel. Also, if you are editing the data being sent, please respect peoples privacy.


  • Revision 1.0 - Article published.
  • Revision 2.0 - Images added, explanation updated


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

CEO Little Apps
Canada Canada

CEO and Founder of Little Apps. Our software programs include:

All of our software is licensed under the GNU General Public License 3.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 4 Pin
Farhan Ghumra18-Jun-12 0:12
memberFarhan Ghumra18-Jun-12 0:12 
GeneralMy vote of 2 Pin
Mark Treadwell9-Aug-09 8:22
memberMark Treadwell9-Aug-09 8:22 
General[My vote of 2] close but no cigar Pin
Donsw12-Jun-09 18:50
memberDonsw12-Jun-09 18:50 
GeneralI give you 3/5 Pin
The Code Guru11-May-09 5:51
memberThe Code Guru11-May-09 5:51 
GeneralMy vote of 2 Pin
Neville Franks30-Apr-09 2:35
memberNeville Franks30-Apr-09 2:35 
GeneralMy vote of 2 Pin
Michael B. Hansen29-Apr-09 21:35
memberMichael B. Hansen29-Apr-09 21:35 
GeneralI like it Pin
Jean-Paul Mikkers29-Apr-09 10:56
memberJean-Paul Mikkers29-Apr-09 10:56 
GeneralMy vote of 1 Pin
Giga7721-Apr-09 4:48
memberGiga7721-Apr-09 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 29 Apr 2009
Article Copyright 2009 by ub3rst4r
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid