public App()
        {
            AppDomain.CurrentDomain.UnhandledException       += this.CurrentDomain_UnhandledException;
            TaskScheduler.UnobservedTaskException            += this.TaskScheduler_UnobservedTaskException;
            Application.Current.DispatcherUnhandledException += this.Dispatcher_UnhandledException;

#if DEBUG
            if (Debugger.IsAttached)
            {
                ServiceController sc = new ServiceController("autosync");

                if (sc.Status == ServiceControllerStatus.Stopped)
                {
                    // Must be started off the UI-thread
                    Task.Run(() =>
                    {
                        Program.SetupOutOfBandInstance();
                    }).Wait();
                }

                return;
            }
#endif

            try
            {
                ConfigClient c = App.GetDefaultConfigClient();
                Trace.WriteLine($"Attempting to connect to the AutoSync service at {c.Endpoint.Address}");
                c.Open();
                Trace.WriteLine($"Connected to the AutoSync service");
            }
            catch (EndpointNotFoundException ex)
            {
                Trace.WriteLine(ex);
                this.ShowDummyWindow();
                MessageBox.Show(
                    $"Could not contact the AutoSync service. Ensure the Lithnet AutoSync service is running",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                Environment.Exit(1);
            }
            catch (System.TimeoutException ex)
            {
                Trace.WriteLine(ex);
                this.ShowDummyWindow();
                MessageBox.Show(
                    $"Could not contact the AutoSync service. Ensure the Lithnet AutoSync service is running",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                Environment.Exit(1);
            }
            catch (System.ServiceModel.Security.SecurityNegotiationException ex)
            {
                Trace.WriteLine(ex);
                this.ShowDummyWindow();
                MessageBox.Show($"There was an error trying to establish a secure session with the AutoSync server\n\n{ex.Message}", "Security error", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(5);
            }
            catch (System.ServiceModel.Security.SecurityAccessDeniedException ex)
            {
                Trace.WriteLine(ex);
                this.ShowDummyWindow();
                MessageBox.Show("You do not have permission to manage the AutoSync service", "Access Denied", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(5);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                this.ShowDummyWindow();
                MessageBox.Show(
                    $"An unexpected error occurred communicating with the AutoSync service. Restart the AutoSync service and try again",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                Environment.Exit(1);
            }
        }