ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/TSControlPanel/Program.cs
(Generate patch)

Comparing trunk/TSControlPanel/Program.cs (file contents):
Revision 60 by william, Thu Jul 12 16:47:17 2012 UTC vs.
Revision 61 by william, Thu Jul 12 17:34:46 2012 UTC

# Line 12 | Line 12 | namespace AnywhereTS
12          /// </summary>
13          [STAThread]
14          static void Main()
15 <        {          
15 >        {
16 >            AppDomain currentDomain = AppDomain.CurrentDomain;
17 >            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
18 >            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
19 >
20              Application.EnableVisualStyles();
21              Application.SetCompatibleTextRenderingDefault(false);
22  
# Line 20 | Line 24 | namespace AnywhereTS
24              objCustomDialogBox.dialogMode = frmClientProperties.ATSClientMode.CONTROL_PANEL; // Select the mode to run the form in.
25              Application.Run(objCustomDialogBox);            
26          }
27 +        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      }
52   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines