public static void Main(string[] args) { try { StartTime = DateTime.Now; CreateMutex(); ProceedCommandLineElevationArguments(args); if (PerformSingleInstanceValidation() || PerformSelfElevation()) { return; } // Nice to know: Its more safe to trigger the AssemblyResolve event in Main(string[] args) only and move all other code to a Main2 method (call Main2 at last in Main) // because the runtime try to bind target/used assemblies(when jump into main) before the AssemblyResolve trigger is established. // But we dont use ouer custom-bind assemblies in this Main(string[] args) so everything is okay. AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Forms.MainForm mainForm = new Forms.MainForm(args); LoadedTime = DateTime.Now - StartTime; Console.WriteLine("DeveloperToolbox loaded in {0} seconds", LoadedTime.TotalSeconds); Application.Run(mainForm); } catch (Exception exception) { if (!_isShutDown) { Forms.ErrorForm.ShowError(null, exception, ErrorCategory.Penalty); } } finally { ReleaseMutex(); } }
public static void Main(string[] args) { try { StartTime = DateTime.Now; CreateMutex(); ProceedCommandLineElevationArguments(args); if (PerformSingleInstanceValidation() || PerformSelfElevation()) return; // Nice to know: Its more safe to trigger the AssemblyResolve event in Main(string[] args) only and move all other code to a Main2 method (call Main2 at last in Main) // because the runtime try to bind target/used assemblies(when jump into main) before the AssemblyResolve trigger is established. // But we dont use ouer custom-bind assemblies in this Main(string[] args) so everything is okay. AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Forms.MainForm mainForm = new Forms.MainForm(args); LoadedTime = DateTime.Now - StartTime; Console.WriteLine("Loaded in {0} seconds", LoadedTime.TotalSeconds); Application.Run(mainForm); } catch (Exception exception) { if (!_isShutDown) Forms.ErrorForm.ShowError(null, exception, ErrorCategory.Penalty); } finally { ReleaseMutex(); } }