Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Jeff Atwood's User Friendly Exception Handling (Or Similar) for C# / Winforms .Net 3.5+?

We have a .Net 3.5 C# / Winforms desktop application with a very limited size/scope/userbase (40 users). I need a way to gather more information about unhandled exceptions, but I don't believe I need anything as big or broad as the Microsoft Exception Handling Application Block*. I just need capture and send.

Is there an exception handler similar in scope and feature set to Jeff Atwood's "User Friendly Exception Handling", for C# on a newer version of .Net? (in my case 3.5, but we eventually hope to move to 4+)

I would love to use ELMAH, but it doesn't work with Winforms.

Alternately, can Jeff Atwood's exception handling work with C# 3.5 / winforms?

*more precisely, I prefer Mr. Atwood's concise 2004 blog post describing his solution and its limited, but useful scope, over the broad and vague documentation of the other. We should all strive to explain components well enough that people are asking for them to be ported to another language 9 years later. ;-)

like image 709
Dan Sorensen Avatar asked Jun 07 '13 18:06

Dan Sorensen


2 Answers

You could set up an unhandled exception handler, then log those exceptions out using a library like ELMAH but configurable from code, given you don't have a web.config.

We use: http://nuget.org/packages/StackExchange.Exceptional/

Catching unhandled exceptions: http://mike.woelmer.com/2009/04/dealing-with-unhandled-exceptions-in-winforms/

like image 97
Matt Davies Avatar answered Sep 20 '22 02:09

Matt Davies


I've been using my own version of Jeff's code for years. It works fine under every target I've ever tried.

Is there a reason you don't think it will work?

Just change the target and rebuild.

like image 40
Brad Bruce Avatar answered Sep 20 '22 02:09

Brad Bruce