public static bool AttachApp()
        {
            try
            {
                AttachExceptionHandler(new UnhandledExceptionHandlerWithUI());
                return(true);
            }
            catch (SecurityException)
            {
                try
                {
                    try
                    {
                        typeof(Application).InvokeMember("EnableVisualStyles", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, null);
                    }
                    catch (MissingMethodException)
                    {
                    }

                    string securityMessage     = string.Format(Localization.CannotAttachApp, ApplicationName);
                    SecurityExceptionForm form = new SecurityExceptionForm(new SecurityExceptionEventArgs(securityMessage, false));
                    form.ShowInTaskbar = true;
                    form.ShowDialog();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString(), string.Format(Localization.FatalError, ApplicationName), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(false);
            }
        }
 protected override void OnSecurityException(SecurityExceptionEventArgs e)
 {
     using (SecurityExceptionForm form = new SecurityExceptionForm(e))
     {
         form.ShowDialog();
     }
 }