internal static void Execute(string[] args, IWindsorContainer container) { var arguments = Arguments.Parse(args); var errorArguments = arguments.Where(x => x.Type == ArgumentType.Unknown || x.Type == ArgumentType.Error).ToList(); if (errorArguments.Count != 0) { MessageBox.Show(Arguments.GetUsageMessage(errorArguments), Core.Application.NameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } AppDomain.CurrentDomain.AssemblyResolve += (s, e) => CustomResolve(e, container); // Issue 180 - Restore the already running instance to the screen. using (var singleInstance = new SingleInstanceHelper()) { if (!CheckSingleInstance(args, singleInstance)) { return; } var logger = container.Resolve <ILogger>(); InitializeLogging(container, logger); if (!CheckMonoVersion(logger)) { return; } var prefs = container.Resolve <IPreferenceSet>(); if (!InitializePreferences(prefs, logger, arguments.Any(x => x.Type == ArgumentType.ResetPrefs))) { return; } if (!ClearCacheFolder(prefs.CacheDirectory, logger)) { return; } LoadPlugins(container); if (!RegisterIpcChannel(container)) { return; } var mainView = container.Resolve <IMainView>(); if (!InitializeMainView(container, arguments, mainView)) { return; } ExceptionDialog.RegisterForUnhandledExceptions( Core.Application.NameAndVersionWithRevision, Environment.OSVersion.VersionString, ex => logger.Error(ex.Message, ex)); System.Windows.Forms.Application.ApplicationExit += (s, e) => { // Save preferences prefs.Save(); }; System.Windows.Forms.Application.Run((Form)mainView); } }