7

I have a .Net process which runs 24/7 which crashes once or twice per week. I have the AppDomain.CurrentDomain.UnhandledException event hooked up to log4net and the event never gets fired! The process just crashes with logging anything! This looks like a .Net runtime/CLR bug as I just get a message in the Event Log saying ".NET Runtime 2.0 Error".

I am running .Net 3.0 Sp1.

Can some please help me figure out how to fix this?

Event log message: .NET Runtime 2.0 Error Type: Error Event Id: 1000

Event log description: Faulting application appName.exe, version 0.0.0.0, stamp 4ca5d33d, faulting module mscorwks.dll, version 2.0.50727.3607, stamp 4add5446, debug? 0, fault address 0x0010724e.

arkina
  • 991
  • 2
  • 11
  • 17

5 Answers5

3

I believe that a StackOverflowException would not be caught like this, as there's nowhere for the code to run. This would possibly be a good candidate for something that occurs on a reasonably regular basis - you may need to check through your code for infinite loops/recursion.

Paddy
  • 33,309
  • 15
  • 79
  • 114
1

Maybe here is your solution

Stecya
  • 22,896
  • 10
  • 72
  • 102
1

So, some interesting feedback, but it may also be worth mentioning that different application types may throw exceptions on different event handlers.

For a Windows Service, we should be safe handling

static void Main (string[] args) 
{
    AppDomain.CurrentDomain.UnhandledException +=
        CurrentDomain_UnhandledException;
}

For a WinForms application, we should also handle the additional unhandled event handler

static void Main (string[] args) 
{
    AppDomain.CurrentDomain.UnhandledException +=
        CurrentDomain_UnhandledException;
    System.Windows.Forms.Application.ThreadException +=
        Application_ThreadException; 
}

For a WPF application, a dispatcher event is provided for GUI exceptions

static void Main (string[] args) 
{
    AppDomain.CurrentDomain.UnhandledException +=
        CurrentDomain_UnhandledException;
    Application.Current.DispatcherUnhandledException +=
        Application_DispatcherException; 
}

Also worth re-iterating, any unhandled exception typically results in program termination. Handling these events however gives us a chance to report and identify the root error.

Additional links that may help

My question regarding unhandled GUI exceptions (duplicate)

WPF global exception handler

Community
  • 1
  • 1
johnny g
  • 3,533
  • 1
  • 25
  • 40
0

Try to place a global try // catch on the entry point of your application.

Hope it helps.

Here it's talking about this error: http://social.msdn.microsoft.com/Forums/en/clr/thread/2d10da32-3f57-4f9b-a509-e9864fc5bd16

alexl
  • 6,841
  • 3
  • 24
  • 29
  • 3
    good advice if the application is single threaded. unfortunately, unhandled exceptions thrown off-thread (by errant child threads in a multi-threaded application) will not be caught - typically resulting in program termination. – johnny g Feb 16 '11 at 16:05
0

look at under error message 2, also a hot fix included, this might or might not be your problem http://code.msdn.microsoft.com/KB913384

Kris Ivanov
  • 10,476
  • 1
  • 24
  • 35