コード例 #1
0
        /// <summary>
        /// Display the exception in the dialog.
        /// </summary>
        public void ShowDialog(string caption, Exception e)
        {
            Text = caption;

            StringBuilder buffer = new StringBuilder();

            buffer.Append("<html><body style='margin:0'>");

            while (e != null)
            {
                string message = e.Message;

                ServiceResultException exception = e as ServiceResultException;

                if (exception != null)
                {
                    message = exception.ToLongString();
                }

                message = ReplaceSpecialCharacters(message);

                if (exception != null)
                {
                    buffer.Append("<p>");
                    buffer.Append("<font style='font:9pt/12pt verdana;color:black'>");
                    buffer.Append(message);
                    buffer.Append("</font>");
                    buffer.Append("</p>");
                }
                else
                {
                    buffer.Append("<font style='font:9pt/12pt verdana;color:red'><b>");
                    buffer.Append(message);
                    buffer.Append("</b></font><br>");
                }

                message = e.StackTrace;

                if (!String.IsNullOrEmpty(message))
                {
                    message = ReplaceSpecialCharacters(message);

                    buffer.Append("<p>");
                    buffer.Append("<font style='font:9pt/12pt verdana;color:black'>");
                    buffer.Append(message);
                    buffer.Append("</font>");
                    buffer.Append("</p>");
                }

                e = e.InnerException;
            }

            buffer.Append("</body></html>");

            ExceptionBrowser.DocumentText = buffer.ToString();

            ShowDialog();
        }