Reputation: 1493
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
The main application screen looks like this
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
Upvotes: 0
Views: 4085
Reputation: 4327
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
Upvotes: 4
Reputation: 1684
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
}
Upvotes: 4