Пример #1
0
        public static void Main(string[] args)
        {
            Application.SetCompatibleTextRenderingDefault(false);
            NBugConfigurator.SetupNBug();

            using (LogWriter.StartLogging())
            {
                try
                {
                    Directory.SetCurrentDirectory(Program.AssemblyLocation.FullName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

                try
                {
                    var instance = new SingleInstanceWrapper();
                    instance.Run(args);
                }
                catch (SocketException ex)
                {
                    Console.WriteLine(ex);
                    SafeRun();
                }
                catch (CantStartSingleInstanceException ex)
                {
                    Console.WriteLine(ex);
                    SafeRun();
                }
            }
        }
        public static void Main(string[] args)
        {
            NBugConfigurator.SetupNBug();

            using (LogWriter.StartLogging())
            {
                try
                {
                    Directory.SetCurrentDirectory(Program.AssemblyLocation.FullName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

                try
                {
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.EnableVisualStyles();

                    _mutex = new Mutex(true, MUTEX_NAME, out var createdNew);
                    if (!createdNew)
                    {
                        _mutex.Dispose();
                        HandleBeingSecondInstance();
                        return;
                    }

                    SetupDependancies();

                    if (Properties.Settings.Default.DpiAwareTest)
                    {
                        Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
                    }

                    var startupMgr = args.Contains("/startupmanager", StringComparison.OrdinalIgnoreCase) ||
                                     args.Contains("/sm", StringComparison.OrdinalIgnoreCase);

                    if (startupMgr)
                    {
                        Application.Run(StartupManagerWindow.ShowManagerWindow());
                    }
                    else
                    {
                        Application.Run(new MainWindow());
                    }
                }
                finally
                {
                    ProcessShutdown();
                }
            }
        }
Пример #3
0
        protected override bool OnStartup(StartupEventArgs eventArgs)
        {
            // Order is semi-important, prepare settings should go first.
            Program.PrepareSettings();
            NBugConfigurator.SetupNBug();
            CultureConfigurator.SetupCulture();
            try
            {
                UpdateSystem.ProcessPendingUpdates();
            }
            catch (Exception ex)
            {
                PremadeDialogs.GenericError(ex);
            }

            // Necessary to put form constructor here for objectlistbox. It flips out if
            // the main form is created inside of the EntryPoint constructor.
            MainForm = new MainWindow();
            return(true);
        }