Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncatchable .NET runtime 2.0 error - user machine - what next?

Situation:

I have an application that uses http connections extensively (stream ripping app) and it is supposed to work 24/7. And it does.

However, occasionally, it crashes with runtime error that is uncaught anywhere, and dumps following to the event log:

Event Type: Error
Event Source:   .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID:   5000
Date:       13.10.2010
Time:       11:02:30
User:       N/A
Computer:   STREAM01
Description:
EventType clr20r3, P1 streamsink.exe, P2 1.0.0.42484, P3 4c880fd9, P4 mscorlib, P5 2.0.0.0, P6 4add54dc, P7 344a, P8 21c, P9 system.io.ioexception, P10 NIL.

My question is: how to know what line of code caused the crash. I am deploying .PDBs with the binaries, but... What to do?

Target is WIndows XP, Framework is 2.0

EDIT:

I have this already implemented:

    static public void InitializeExceptionHandler(string AppName) {
        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
        Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
        AppDomain currentDomain = AppDomain.CurrentDomain;
        currentDomain.UnhandledException+=new UnhandledExceptionEventHandler(currentDomain_UnhandledException);
        _appName=AppName;
    }

No, it doesn't work!

like image 340
Daniel Mošmondor Avatar asked May 24 '26 21:05

Daniel Mošmondor


2 Answers

Register current domain's unhandled exception in the entry point (Main() or ...):

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

Implement logging in the handler:

static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            // log
        }

Application will still crash but you will get the full logging of what happened and stack trace.

UPDATE

According to the update you have, I suggest you download debugging tools for windows http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx and then enable post-mortem debugging and make sure a crash dump is created (see Enabling Postmortem Debugging section in Windbg help file) and use Windbg to debug your dump to find out where it has crashed.

like image 70
Aliostad Avatar answered May 26 '26 09:05

Aliostad


Maybe this article will be helpful A Simple Class to Catch Unhandled Exceptions in WinForms

UPDATE:

It very strange.. So grab ProcDump, write batch file and ask your customer to run it when he see error message. Get dump and try to investigate it via WinDbg or VS 2010. Here some more information.

Also check: Creating and analyzing minidumps in .NET production applications. If you are new to WinDbg, check Tess Ferrandez's blog

Another way go with Remote Debugging Setup

like image 31
Nick Martyshchenko Avatar answered May 26 '26 10:05

Nick Martyshchenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!