コード例 #1
0
        protected override void OnSecurityException(SecurityExceptionEventArgs e)
        {
            LogError(e.SecurityException);
            var form = new SecurityExceptionForm(e);

            form.ShowDialog();
        }
コード例 #2
0
        public SecurityExceptionForm(SecurityExceptionEventArgs securityExceptionEventArgs)
            : this()
        {
            if (securityExceptionEventArgs == null) return;

            if (!securityExceptionEventArgs.CanContinue) this.continueButton.Visible = false;

            this.securityExceptionEventArgs = securityExceptionEventArgs;

            if (securityExceptionEventArgs.SecurityMessage.Length > 0)
            {
                this.errorMessage.Text = securityExceptionEventArgs.SecurityMessage;
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("{0} attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system administrator, or use the Microsoft .NET Framework Configuration tool.\n\n", UnhandledExceptionHandler.ApplicationName);

                if (securityExceptionEventArgs.CanContinue)
                {
                    sb.Append("If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.\n\n");
                }

                sb.Append(securityExceptionEventArgs.SecurityException.Message);
                this.errorMessage.Text = GetConvertedString(sb.ToString());
            }

            int newClientHeigth = errorMessage.Bottom + 60;
            if (newClientHeigth > ClientSize.Height) ClientSize = new Size(ClientSize.Width, newClientHeigth);
        }
コード例 #3
0
 protected override void OnSecurityException(SecurityExceptionEventArgs e)
 {
     using (SecurityExceptionForm form = new SecurityExceptionForm(e))
     {
         form.ShowDialog();
     }
 }
コード例 #4
0
        public SecurityExceptionForm(SecurityExceptionEventArgs securityExceptionEventArgs) : this()
        {
            if (securityExceptionEventArgs == null)
            {
                return;
            }

            if (!securityExceptionEventArgs.CanContinue)
            {
                continueButton.Visible = false;
            }

            this.securityExceptionEventArgs = securityExceptionEventArgs;

            if (securityExceptionEventArgs.SecurityMessage.Length > 0)
            {
                errorMessage.Text = securityExceptionEventArgs.SecurityMessage;
            }
            else
            {
                var sb = new StringBuilder();
                sb.Append(
                    "%AppName% attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system administrator, or use the Microsoft .NET Framework Configuration tool.\n\n");

                if (securityExceptionEventArgs.CanContinue)
                {
                    sb.Append(
                        "If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.\n\n");
                }

                sb.Append(securityExceptionEventArgs.SecurityException.Message);
                errorMessage.Text = GetConvertedString(sb.ToString());
            }

            var newClientHeigth = errorMessage.Bottom + 60;

            if (newClientHeigth > ClientSize.Height)
            {
                ClientSize = new Size(ClientSize.Width, newClientHeigth);
            }
        }
コード例 #5
0
        public SecurityExceptionForm(SecurityExceptionEventArgs securityExceptionEventArgs)
        {
            InitializeComponent();

            Icon = Win32.GetApplicationIcon();
            Text = UnhandledExceptionHandler.ApplicationName;
            if (Text.Length == 0)
            {
                Text = Localization.SecurityException;
            }

            this.securityExceptionEventArgs = securityExceptionEventArgs;
            if (!securityExceptionEventArgs.CanContinue)
            {
                continueButton.Visible = false;
            }

            if (securityExceptionEventArgs.SecurityMessage.Length > 0)
            {
                errorMessage.Text = securityExceptionEventArgs.SecurityMessage;
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(string.Format(Localization.SecurityExceptionMessage, UnhandledExceptionHandler.ApplicationName));
                if (securityExceptionEventArgs.CanContinue)
                {
                    sb.Append(Localization.ContinueOrQuit);
                }
                sb.Append(securityExceptionEventArgs.SecurityException.Message);
                errorMessage.Text = sb.ToString();
            }

            int newClientHeigth = errorMessage.Bottom + 60;

            if (newClientHeigth > ClientSize.Height)
            {
                ClientSize = new Size(ClientSize.Width, newClientHeigth);
            }
        }
コード例 #6
0
 protected override void OnSecurityException(SecurityExceptionEventArgs e)
 {
     SecurityExceptionForm form = new SecurityExceptionForm(e);
     form.ShowDialog();
 }
 protected override void OnSecurityException(SecurityExceptionEventArgs e) {
     LogError(e.SecurityException);
     var form = new SecurityExceptionForm(e);
     form.ShowDialog();
 }
コード例 #8
0
ファイル: Class1.cs プロジェクト: MaHuJa/withSIX.Desktop
 protected override void OnSecurityException(SecurityExceptionEventArgs e) {
     //LogError(e.FatalException);
     MessageBox.Show(e.SecurityMessage + "\n" + e.SecurityException,
         string.Format("{0} Security Error", ApplicationName),
         MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
 protected override void OnSecurityException(SecurityExceptionEventArgs e)
 {
     e.ReportException = true;
 }