.NET "Send a bug report to [me]"

If the exception extends to the very top of my application (which, of course, will never happen), I would like to suggest the option of sending an error report before the program crashes. What I mean is wrapping everything in the Main function in a try-catch and a small class that sends the stack trace and other information to my server. It sounds simple enough, but with something like that, I am sure that there are obstacles (such as security, future verification) that I have not fully considered.

Is there an existing .NET library / project for this purpose? Or, alternatively, does this sound like the right approach, just catching all the Exception at the application entry point?

+6
exception error-handling
source share
7 answers

See this question in all available .NET logging frameworks, any of which should offer email notification.

I find it best to have a top-level exception handler that collects and writes data about uncaught exceptions. As Meeh mentions in his comment on your question, you need one for each thread in your application.

There is an old article from Joel about the error reporting function in FogBugz, maybe this will give you some more ideas. (I think I read it on my blog, but all I could find was this page that makes up the FogBugz documentation).

+4
source share

You can use the logging unit from the corporate library to easily send emails when you catch and register exceptions. Here is some information on how to create a last chance exception handler . I assumed that you have a Winform application, but this is not clear from your question.

+2
source share

Use the same tools that Windows uses: Windows Error Reporting (WER). It will analyze the failures and execute your emergency situations so that you can understand which ones are the most common. No code changes are required; it works at the process level. It will log errors due to exceptions that you cannot catch.

Everything is assumed that you are running Windows, of course.

+1
source share

My standard disclaimer: I am the developer of this product.

Using the product (Runtime Intelligence) written by the company I'm working on (PreEmptive Soltutions), you can enter not only an error report, but also the ability to track when users use your applications and what features they use with minimal coding.

Using Dotfuscator to perform code injection (or IL merge), we embed new code in your application binaries, which send usage data to a server hosted on our site (or, possibly, to any other arbitrary URL). If you send us data, we provide you with a number of powerful analysis tools and usage reports.

The basic version of this function should be included in Visual Studio 2010, as well as access to a free portal for data transfer (but without SLA, guarantees of data storage or data privacy).

The ability to send arbitrary data along with usage information is limited to the commercial product, but you can contact PreEmptive Soltutions for a fully functional free version with a limited time.

You can run the error report using the sample code below:

public partial class app : Application { // field to temporarily store exception data private Exception exp; void AppStartup(object sender, StartupEventArgs args) { // add a handler to catch any unhandled exceptions this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(ErrorHandler); Window1 mainWindow = new Window1(); mainWindow.ShowDialog(); } // this will prompt the user if they want to report the exception void ErrorHandler(object sender, DispatcherUnhandledExceptionEventArgs e) { this.exp = e.Exception; if (MessageBox.Show("A " + exp.Message + " exception happened, should I report it?", "Error Occurrend", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ErrorHappened(); e.Handled = true; } } // this method is called by the above ErrorHandler method and when run through Dotfuscator additional code will be injected into this method that will send a usage data message back to the server and the data in the dictionary (which will be exception data) returned by the ErrorData method will be included into the message and be stored and reported on the server [Feature("Exception", EventType = FeatureEventTypes.Tick, ExtendedKeySourceElement = SourceElements.Method, ExtendedKeySourceName = "ErrorData")] private void ErrorHappened() { // This is here as a placeholder for the exception feature attribute which will exit the application when executed AppShutdown(true); } // this method takes the exception data from the exp field and returns it as a dictionary of name/value pairs public Dictionary<string, string> ErrorData() { var retval = new Dictionary<string,string>(); if (null != exp) { retval.Add("Error Message",exp.Message); retval.Add("Stack Trace",exp.StackTrace); } return retval; } } 
+1
source share

I changed the Jeff Friendly exception handler and updated it for .NET 2.0 / 3.5, and I got lucky with it. If the exception does all this to an uninstalled stack, the picture is taken and sent via email along with a detailed stack trace to the development team.

+1
source share

I am working on an Exceptionless open source project that has client libraries that do just that! We capture all unhandled exceptions and send them to rest api, and then process them in real time.

https://github.com/exceptionless/Exceptionless

+1
source share

If you are working on an ASP.NET application, you can also use ASP.NET health monitoring features. Attracted to add multiple lines to the configuration file, and you are disabled. http://msdn.microsoft.com/en-us/library/bb398933.aspx

0
source share

All Articles