What is the best way to collect / report unexpected errors in .NET Window applications?

I am looking for a better solution than the fact that we are currently dealing with unexpected production errors without reinventing the wheel.

Most of our products are WinForm and WPF applications installed on remote sites. Unexpected errors inevitably occur: from NullReferenceExceptions to "General Network Errors." Thus, from programmer errors to environmental problems.

Currently, all of these unhandled exceptions are logged with log4net and then emailed to us for analysis . However, we found that sometimes these error messages contain too little information to identify the problem.

In these reports we need information, for example:

  • app name
  • Application version
  • work station
  • Maybe screenshot
  • Exception Details
  • operating system
  • Available RAM
  • Process start
  • And so on...

I do not want to reinvent the wheel, developing it from scratch. Necessary components:

  • Error collection (details as above)
  • Error 'sender' (queue is required if DB or Internet is not available)
  • Error database
  • Analysis and reporting of these errors. For example. The 10 most common errors or timeouts occur between 16:00 and 17:00. How to compare errors between versions x and y?

Note: We considered SmartAssembly as a possible solution, but although this did not nearly satisfy our needs, I was hoping to hear what other developers do and if there are some alternatives.

Edit: Thanks for the answers. Perhaps in my initial question I was not clear, the problem is not how to catch all rash exceptions, but how to deal with them and create a reporting (analysis) mechanism around them.

+6
c # error-handling reporting
source share
3 answers

I would suggest an article by Jeff Atwood on β€œConvenient Exception Handling,” which does most of what you ask for (Application Info, Screenshot, Exception Details, OS, Writing to Text Files, and Emailing), and contains the source code, so you add the extra material you need.

+5
source share

You can attach an exception to the unhandled event and register it / hit the web service / etc.

[STAThread] static void Main() { Application.ThreadException += new ThreadExceptionEventHandler(OnUnhandledException); Application.Run(new FormStartUp()); } static void OnUnhandledException(object sender, ThreadExceptionEventArgs t) { // Log } 

I also found this piece of code using AppDomain instead of ThreadException:

 static class EntryPoint { [MTAThread] static void Main() { // Add Global Exception Handler AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException); Application.Run(new Form1()); } // In CF case only, ALL unhandled exceptions come here private static void OnUnhandledException(Object sender, UnhandledExceptionEventArgs e) { Exception ex = e.ExceptionObject as Exception; if (ex != null) { // Can't imagine e.IsTerminating ever being false // or e.ExceptionObject not being an Exception SomeClass.SomeStaticHandlingMethod(ex, e.IsTerminating); } } } 

Here are some documents on it: AppDomain Unhandled Exception

Except that you just process it yourself, there really is no general way to do this that can be reused, you really need to integrate it with the application interface correctly, but you can set up a web service that accepts the application name, exception and all these are good things and have a centralized point for all your applications.

+2
source share

You might want to explore the error reporting feature built into the JetBrain Omea Reader . It has a comprehensive error handling component that invokes dialogue when an unexpected error occurs. You can enter additional information before submitting a problem to the JetBrain error reporting web service.

They made Omea open source to allow the community to upgrade the .NET 1.1 database to version v2 or 3. http://www.jetbrains.net/confluence/display/OMEA/this+link

0
source share

All Articles