views:

455

answers:

2

The program spits up one of those boxes saying an unhandled exception has occurred and the application must quit. The only clue I get to solve the problem is this in the event log:

Event Type: Error Event Source: .NET Runtime 2.0 Error Reporting Event Category: None Event ID: 5000 Date: 1/9/2009 Time: 8:47:44 AM User: N/A Computer: DADIEHL Description: EventType clr20r3, P1 crm.client.exe, P2 1.0.1.0, P3 49667f61, P4 mscorlib, P5 2.0.0.0, P6 471ebc5b, P7 c35, P8 59, P9 system.formatexception, P10 NIL.

So I added the following code to program.cs:

try
{
    Application.Run(new WindowContainer());
}
catch (Exception exc)
{
    new DialogException(exc).ShowDialog();
}

Just so I could catch any exception, but the users are still getting the same message that says the app has to quit. I cannot reproduce this on my computer and thus can't use the debugger to narrow it down. Does anyone know of a way to collect more information or have any ideas what the issue is?

+11  A: 

It may well be that the exception is being thrown on a different thread.

Two events you may want to add handlers to:

Add handlers which log the exception and you'll have a lot more information.

The behaviour of unhandled exceptions in non-UI threads changed from .NET 1.1 to 2.0. They used to just be swallowed but now they halt the app. There's an app.config flag you can use to choose the old behaviour if you want - but it's not really recommended, as an exception in another thread may well mean that your app is now unstable. I can't remember the details of the setting at the minute, but I can look them up if you want.

Jon Skeet
Thank you. I'm fighting this now, and this is the first useful post I've found after several hours of googling.
David Stratton
A: 

If you don't want to make code changes right this second, I'd probably use WinDbg with the SOS extension, so you can at least get a stack trace - very handy for these types of crashes.

Real World Walkthrough w/WinDbg

You could try handling the UnhandledExceptionEvent. From MSDN:

UnhandledExceptionEvent

Lurker Indeed