public static void Main(string[] args) { #pragma warning disable ResourceUtility.InitResources(); #if DEBUG //为应用程序启用可是样式 Application.EnableVisualStyles(); //是否以Debug模式运行 if (Debugger.IsAttached) { Run(args); return; } #endif #if !DEBUG string exeDir = Path.GetDirectoryName(typeof(SolarViewerFrameworkMain).Assembly.Location); bool createdNew; using (Mutex mutex = new Mutex(true, "StartUp" + exeDir.GetHashCode(), out createdNew)) { if (!createdNew) { return; } //判断参数是否包含 "/noupdate"。 bool bStartAutoUpdate = true; foreach (string arg in args) { if (arg == "/noupdate") { bStartAutoUpdate = false; break; } } //需要更新。 if (bStartAutoUpdate) { StartAutoUpdate(); return; } #endif // Do not use LoggingService here (see comment in Run(string[])) try { Run(args); } catch (Exception ex) { try { HandleMainException(ex); } catch (Exception loadError) { MessageBox.Show(loadError.ToString(), "Critical error (Logging service defect?)"); } } #if !DEBUG } #endif }