开发者

.NET Runtime Error causes process to crash! But there's no unhandled exception - Why? CLR bug?

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 run开发者_如何转开发time/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.


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.


Maybe here is your solution


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜