private void OnStartup(object sender, StartupEventArgs eventArgs)
        {
            // Attach an unhandled exception handler that reports the exception
            // to app insights, logs it, and informs the user of it.
            AppDomain.CurrentDomain.UnhandledException += (o, args) =>
            {
                var ex = (args.ExceptionObject as Exception);

                ClientAppInsights.TelemetryClient.TrackException(ex);
                ClientAppInsights.Shutdown();

                Utilities.Log(ex);

                var body = "";
                while (ex != null)
                {
                    // Don't display the typical outer exception, just the inner exceptions.
                    const string unneededOuterExceptionMessage
                        = "The invocation of the constructor on type 'AdventureWorksSalesClient.LoginDialog' that matches the specified binding constraints threw an exception.";
                    if (!ex.Message.Contains(unneededOuterExceptionMessage))
                    {
                        body += $"\n* {ex.Message}";
                    }
                    ex = ex.InnerException;
                }

                if (body == "")
                {
                    body = "Unknown error.";
                }
                Utilities.ShowErrorDialog($"An unexpected error occurred. " +
                                          $"Please contact Adventure Works technical support. " +
                                          $"The error was:\n{body}", "An error occurred");
            };
        }
 internal static void ReportTampering(bool isTampered)
 {
     if (isTampered)
     {
         ClientAppInsights.TelemetryClient.TrackEvent("Tampering Detected");
         ClientAppInsights.Shutdown();
     }
 }