Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unhandled exception logging for Windows Forms

Is there anything like ELMAH for Windows Forms?

I'm looking for a standard way to process unhandled exceptions and grab a screenshot and other environment information before packaging that up for support.

like image 927
Matt Everson Avatar asked Sep 15 '08 20:09

Matt Everson


People also ask

How to write exception in log file?

To log a handled exceptionCreate the method that will generate the exception information. Use a Try...Catch block to catch the exception. Put the code that could generate an exception in the Try block. Uncomment the Dim and MsgBox lines to cause a NullReferenceException exception.

What is an unhandled exception?

An unhandled exception is an error in a computer program or application when the code has no appropriate handling exceptions. Learn about the definition and examples of unhandled exceptions, and explore programming and exception handlers.

What is unhandled exception in C#?

An unhandled exception occurs when the application code does not properly handle exceptions. For example, When you try to open a file on disk, it is a common problem for the file to not exist.

How to log exception in c#?

We suggest logging your exceptions using NLog, Serilog, or log4net. All three frameworks give you the ability to log your exceptions to a file. They also allow you to send your logs to various other targets. These things like a database, Windows Event Viewer, email, or an error monitoring service.


2 Answers

The very same Jeff Atwood coded a nice solution (albeit in VB.NET) which I had to modify and "fix" but that I am happily using since then.

You can view his solution Here

like image 76
Martin Marconcini Avatar answered Oct 21 '22 15:10

Martin Marconcini


There is a nice User Friendly Exception Handling made by Jeff Atwood in 2004. I used it for several of our internal applications and it worked well.

like image 20
Pascal Paradis Avatar answered Oct 21 '22 15:10

Pascal Paradis