/[AnywhereTS-MSSQL]/trunk/TSControlPanel/Program.cs
ViewVC logotype

Annotation of /trunk/TSControlPanel/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (hide annotations) (download)
Thu Jul 12 17:34:46 2012 UTC (9 years ago) by william
File size: 2198 byte(s)
+ more wip for unhandled exception

1 william 4 using System;
2     using System.Collections.Generic;
3     using System.Windows.Forms;
4 william 52 using System.Data.SqlClient;
5 william 4
6     namespace AnywhereTS
7     {
8     static class Program
9     {
10     /// <summary>
11     /// The main entry point for the application.
12     /// </summary>
13     [STAThread]
14     static void Main()
15 william 61 {
16     AppDomain currentDomain = AppDomain.CurrentDomain;
17     currentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
18     Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
19    
20 william 4 Application.EnableVisualStyles();
21     Application.SetCompatibleTextRenderingDefault(false);
22    
23     frmClientProperties objCustomDialogBox = new frmClientProperties();
24     objCustomDialogBox.dialogMode = frmClientProperties.ATSClientMode.CONTROL_PANEL; // Select the mode to run the form in.
25     Application.Run(objCustomDialogBox);
26     }
27 william 61 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args)
28     {
29     Exception e = (Exception)args.ExceptionObject;
30     if (e == null)
31     {
32     Logging.ATSAdminLog.Error("Encountered unhandled Exception, but the exception was null");
33     return;
34     }
35     if (e.GetType() == typeof(SqlException))
36     {
37     SqlException sql_ex = (e as SqlException);
38     using (log4net.NDC.Push(string.Format("SqlException: ID={0} MESSAGE={1}{2}Diagnostics:{2}{3}", sql_ex.Number.ToString(), sql_ex.Message, System.Environment.NewLine, sql_ex.ToString())))
39     {
40     Logging.ATSAdminLog.Error("Encountered unhandled SqlException");
41     }
42     }
43     else
44     {
45     using (log4net.NDC.Push(string.Format("Exception: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
46     {
47     Logging.ATSAdminLog.Error("Encountered unhandled Exception");
48     }
49     }
50     }
51 william 4 }
52     }

  ViewVC Help
Powered by ViewVC 1.1.22