views:

138

answers:

2

Is there a facility similar to ELMAH but for non-ASP applications? One that will handle all unhandled exceptions and write them to multiple sources?

Or is there some way to easily capture all unhandled exceptions, similar to Application_Error in an ASP.NET Global.asax.cs file? If that can be done, I can then just use NLog or similar to log them. Was just hopeful a framework similar to ELMAH existed.

A: 

You CAN capture unhandled exceptions in a WinForms app. This previous post contains the answer you are looking for.

http://stackoverflow.com/questions/2770/global-exception-handling-for-winforms-control

Edit - added

Actually, here is a nicer article outlining how to do this.

http://msmvps.com/blogs/deborahk/archive/2009/09/02/global-exception-handler-winforms.aspx

David Stratton
Thanks, I'll investigate. No framework to make it as easy as ELMAH, though, right? Might be a fun side project. :)
Lemonbased
We wrote our own framework for exception handling. it logs all error messages to one of five locations, the first choice being a centralized database where we're logging errors for ALL of our applications. It only took about a day to write, and it's been the best investment we've made. We rolled our own because nothing existing met our needs completely.
David Stratton