Question

I am developing an application in Visual C# using winforms.

The application is basically a screen with three tabs. It shows values from processes running on the system per second (using System.Diagnostics.Process[] ).

It generates and updates lot of numbers and calculations (around 4000/second). But after 10000 iterations or ~45 minutes of work, it just crashes and the amazing part is It always crashes around the same time.

The RAM involved here is just 70mb and CPU load never goes above 35% for the app under windows xp and windows 7. The aim of the app is to allow users to view processes running on the system with the cpuload and memory load. we cannot suggest taskmanager due to security reasons.

The error is not trapped by C# by any of the try - catch methods

Following screens are a sample that follow after the crash

enter image description here

The main application screen looks like this

enter image description here

Has anybody faced such a situation where the app crashes after a fixed run length.

Please suggest a diagnostic tool or a method to trap such errors.

Thanks for the replies

Was it helpful?

Solution

Try adding this into your service in the main void

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

        public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            // do your logging here, write to a file, or send an email
        }

and

service.ExceptionThrown += service_ExceptionThrown;

        private static void service_ExceptionThrown(object sender, ExceptionThrownEventArgs e)
        {
            // do your logging here, write to a file, or send an email
        }

and if you want to debug your service in visual studio then just add -d by start up option in the Command line arguments

Command line argumnets

OTHER TIPS

If you have Visual Studio installed on this machine, you should be able to debug the application, when it crashes. At least you should see which exception is thrown and where.

In my application I have a handler, which catches uncatched exceptions and writes them to a logfile.

Add to the constructor

AppDomain currDomain = AppDomain.CurrentDomain;
currDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExHandler);

and add also this handler

private void UnhandledExHandler(object sender, UnhandledExceptionEventArgs args)
{
    Exception e = (Exception)args.ExceptionObject;
    // Log the exception here
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top