From c5b362497be1dd565148d440b8d43cbed4dd9349 Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 3 Nov 2010 16:21:42 +0000 Subject: [PATCH] --- PROMS/VEPROMS User Interface/Program.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/PROMS/VEPROMS User Interface/Program.cs b/PROMS/VEPROMS User Interface/Program.cs index 2ff93064..248ea598 100644 --- a/PROMS/VEPROMS User Interface/Program.cs +++ b/PROMS/VEPROMS User Interface/Program.cs @@ -6,6 +6,7 @@ namespace VEPROMS { static class Program { + private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// /// The main entry point for the application. /// @@ -14,7 +15,29 @@ namespace VEPROMS { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmVEPROMS()); + if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().EndsWith("vshost")) + { + Application.Run(new frmVEPROMS()); + } + else + { + Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + Application.Run(new frmVEPROMS()); + } + } + + static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + _log.Error("PROMS2010 Main UnhandledException", e.ExceptionObject as Exception); + Application.Exit(); + } + + static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) + { + _log.Error("PROMS2010 Main ThreadException", e.Exception); + Application.Exit(); } } } \ No newline at end of file