private static void RunApplication() { LoggingService.Info("Starting Application..."); try { if (!Debugger.IsAttached) { Application.ThreadException += new ThreadExceptionEventHandler(AppEntry.ShowErrorBox); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppEntry.ShowErrorBox); } RightToLeftConverter.RightToLeftLanguages = new string[0]; Assembly assembly = typeof(AppEntry).Assembly; CoreStartup startup = new CoreStartup("评估管理系统"); LoggingService.Info("Starting core services..."); startup.StartCoreServices(); ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", assembly)); ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", assembly)); RegisterDoozers(); LoggingService.Info("Looking for AddIns..."); startup.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "AddIns")); startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), Path.Combine(PropertyService.ConfigDirectory, "AddIns")); LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); LoggingService.Info("Initializing workbench..."); WorkbenchSingleton.InitializeWorkbench(); if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.Dispose(); } bool flag = true; try { LoggingService.Info("Starting workbench..."); new StartWorkbenchCommand().Run(SplashScreenForm.GetRequestedFileList()); flag = false; } finally { LoggingService.Info("Unloading services..."); try { FileService.Unload(); PropertyService.Save(); } catch (Exception exception) { if (flag) { LoggingService.Warn("Exception during unloading after exception", exception); } else { MessageService.ShowError(exception); } } } } finally { LoggingService.Info("Leaving RunApplication()"); } }
static void RunApplication() { LoggingService.Info("Starting Application..."); try { #if DEBUG if (!Debugger.IsAttached) { Application.ThreadException += ShowErrorBox; AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; } #else Application.ThreadException += ShowErrorBox; AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; MessageService.CustomErrorReporter = ShowErrorBox; #endif // disable RTL: translations for the RTL languages are inactive RightToLeftConverter.RightToLeftLanguages = new string[0]; Assembly exe = typeof(AppEntry).Assembly; FileUtility.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); CoreStartup c = new CoreStartup("SMOA"); c.ConfigDirectory = FileUtility.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".SkyMapSoft", ((AssemblyProductAttribute)exe.GetCustomAttributes(typeof(AssemblyProductAttribute), true)[0]).Product) + Path.DirectorySeparatorChar; LoggingService.Info("Starting core services..."); c.StartCoreServices(); ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", exe)); ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", exe)); RegisterDoozers(); LoggingService.Info("Looking for AddIns..."); c.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "AddIns")); c.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); c.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), Path.Combine(PropertyService.ConfigDirectory, "AddIns")); LoggingService.Info("Loading AddInTree..."); c.RunInitialization(); LoggingService.Info("Initializing workbench..."); // .NET base autostarts // taken out of the add-in tree for performance reasons (every tick in startup counts) WorkbenchSingleton.InitializeWorkbench(); if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.Dispose(); } bool exception = true; // finally start the workbench. try { LoggingService.Info("Starting workbench..."); new StartWorkbenchCommand().Run(SplashScreenForm.GetRequestedFileList()); exception = false; } finally { LoggingService.Info("Unloading services..."); try { FileService.Unload(); PropertyService.Save(); //CacheService.Unload(); } catch (Exception ex) { if (exception) LoggingService.Warn("Exception during unloading after exception", ex); else MessageService.ShowError(ex); } } } finally { LoggingService.Info("Leaving RunApplication()"); } }
private static void Main(string[] args) { FileUtility.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."); Environment.CurrentDirectory = FileUtility.ApplicationRootPath; if (args.Length > 0) { string str = args[0].ToLower(); if ((str != null) && (((str == "start") || (str == "stop")) || (str == "restart"))) { ControlService(args[0].ToLower()); return; } } LoggingService.Info("Start application...."); CoreStartup startup = new CoreStartup("置信远程应用服务"); startup.RunInitialization(); startup.StartCoreServices(); if (ConfigurationSettings.AppSettings["remoting"] != "off") { RegisterRemoting(); DAOCacheService.LoadCaches(); } if (args.Length == 0) { StartService(); } else { RunAsConsole(); } }