I have an application in C# for Windows Mobile 6.5 . The problem is that after a lot of time of use (2-3 hours), sometimes the app crashes with "NullReferenceException" in Main().
I have all the program with try catch, testing in main to catch different exceptions (ObjectDisposed, NullException and Exception), and also I've tried with the event:
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(OnUnhandledException);
The applications is still hanging after a time of use. Does anybody know any app to monitor this crashes like DebugDiag in Windows, or some piece of code to catch in a log this exception?
Code in main function is as follows:
static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(OnUnhandledException);
try
{
CLog.EscribirEnLog("Main");
using (AppExecutionManager execMgr = new AppExecutionManager(appName))
{
if (execMgr.IsFirstInstance)
{
Application.Run(new FormInicioSesion());
CUtiles.MatarProceso("FoxitReader.exe");
CUtiles.MatarProceso("pimg.exe");
}
}
}
catch (NullReferenceException ex)
{
CLog.EscribirEnLog("ERROR Null " + ex.StackTrace);
Application.Exit();
}
catch (ObjectDisposedException e)
{
CLog.EscribirEnLog("ERROR : Excepcion en main : " + e.StackTrace.ToString() + "; " + e.InnerException.ToString() + "; " + e.Message.ToString());
Application.Exit();
}
catch (Exception e)
{
CLog.EscribirEnLog("ERROR : Excepcion : " + e.StackTrace.ToString() + "; " + e.InnerException.ToString() + "; " + e.Message.ToString());
Application.Exit();
}
finally
{
CLog.EscribirEnLog("Main-Finally");
}
}