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

Contents of /trunk/TSAdminTool/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (show annotations) (download)
Thu Jul 12 17:34:46 2012 UTC (8 years, 6 months ago) by william
File size: 1980 byte(s)
+ more wip for unhandled exception

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

  ViewVC Help
Powered by ViewVC 1.1.22