views:

131

answers:

6

I want to create a mecanism in a large .net application to handle all the exceptions in the application, and to save the error messages (in db or log file) so these errors can be fixed, and so we are aware of the problems in the application.

Does anyone know a good way of creating a library to handle and process all the exceptions?. Are there any tools around that can simplify my task. What aproach would you suggest me to take....

If you previously implemented something similar to what I want to do, I do want to heard from you

Thanks all

+1  A: 

Would something like Exceptioneer be akin to what you are looking for?

Colin Mackay
+2  A: 

Exceptioneer is a fantastic product.

There are a couple of others:

http://logging.apache.org/log4net/

Also The logging application Block

http://msdn.microsoft.com/en-us/library/dd139916.aspx

Si Philp
+1  A: 

First thing you need is a logger. Log4Net is a good one.

Then you can log exceptions in the try catch blocks and you can subscribe to CurrentDomain_UnhandledException and Application_ThreadException to catch any unhandled exceptions and log those using the logger

chikak
A: 

Catching exceptions and then handling them are two quite different issues in exceptions in .NET. There are a number of tools such as log4net that give you a nice way to do something with an exception, once you have caught it.

But the catching in the first place is not as simple as you might expect. In fact it appears that it is simply not possible to handle every type of exception that could be thrown.

See these other questions for information on the issue you can run into.

whats-the-best-way-to-implement-a-catch-all-exceptions-handler

how-to-catch-all-exceptions-crashes-in-a-net-app

stackoverflowexception-in-.net

There are also other issues to do with handling exceptions that occur in other threads such as is explained here. In short it is surprisingly tricky.

I'm not aware of a library or framework that encompases the catching of ALL possible exceptions. I'd be very interested to hear about one if anyone does.

Ash
A: 

Have a look at SmartInspect

Conrad
+1  A: 

You should take a look at CodeSmith Insight. We use it in our commercial application and it has been a dream come true. We were using Fogbugz before and we evaluated a bunch of other products. It allows you to serialize whole objects as well as sends back a lot of extra information that helps in fixing bugs (Tracing, logs, tags, screenshot, user comments and much more). This cuts out time in solving the issue by having a ton of information at your finger tips as well as the ability to ask the user who encountered the error for more information.

It features a rich API and pre-built in clients for a bunch of technologies. There are samples in WinForms, Silverlight, WPF, MVC and more.

Blake Niemyjski