123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using ProjectManagementSystem.Common.Extenions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace ProjectManagementSystem
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- //Application.Run(new MainForm());
- Program.InitApplication();
- }
- public static void InitApplication()
- {
- System.Windows.Forms.Application.ThreadException += Application_ThreadException;
- System.AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
- try
- {
- bool flag;
- using (new System.Threading.Mutex(true, "Global\\" + System.Windows.Forms.Application.ProductName, out flag))
- {
- if (flag)
- {
- string cultureInfo = Common.Function.AppSetting.TryGetValue<string>("CultureInfo");
- if(!string.IsNullOrEmpty(cultureInfo))
- {
- System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cultureInfo);
- }
- Application.Run(new MainForm());
- }
- else
- {
- MessageBox.Show("应用程序只能启动一个实例!!!");
- Application.Exit();
- }
- }
- }
- catch (System.Exception exception)
- {
- Common.Logger.CLog.Instance.SystemLog.WriteExceptionCaller(exception);
- MessageBox.Show("应用程序运行异常!!!" + exception.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- Application.Exit();
- }
- }
- private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- Exception exception = e.ExceptionObject as Exception;
- Common.Logger.CLog.Instance.SystemLog.WriteExceptionCaller(exception);
- MessageBox.Show("应用程序有未处理的异常!!!" + exception.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
- {
- Common.Logger.CLog.Instance.SystemLog.WriteExceptionCaller(e.Exception);
- MessageBox.Show("应用程序线程异常!!!" + e.Exception.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
|