ExceptionMessageBox 类

定义

显示可使用文本、按钮和符号自定义的消息框,以改进基于 Microsoft Windows .NET Framework 的应用程序的客户体验。

public ref class ExceptionMessageBox
[System.Runtime.InteropServices.ComVisible(false)]
public class ExceptionMessageBox
[<System.Runtime.InteropServices.ComVisible(false)>]
type ExceptionMessageBox = class
Public Class ExceptionMessageBox
继承
ExceptionMessageBox
属性

示例

本示例显示带有 “确定 ”按钮的消息框。

try
{
    // Do something that may generate an exception.
    throw new ApplicationException("An error has occured");
}
catch (ApplicationException ex)
{
    // Define a new top-level error message.
    string str = "The action failed.";

    // Add the new top-level message to the handled exception.
    ApplicationException exTop = new ApplicationException(str, ex);
    exTop.Source = this.Text;

    // Show an exception message box with an OK button (the default).
    ExceptionMessageBox box = new ExceptionMessageBox(exTop);
    box.Show(this);
}
Try
    ' Do something that may generate an exception.
    Throw New ApplicationException("An error has occured")
Catch ex As ApplicationException
    ' Define a new top-level error message.
    Dim str As String = "The action failed."

    ' Add the new top-level message to the handled exception.
    Dim exTop As ApplicationException = New ApplicationException(str, ex)
    exTop.Source = Me.Text

    ' Show an exception message box with an OK button (the default).
    Dim box As ExceptionMessageBox = New ExceptionMessageBox(exTop)
    box.Show(Me)
End Try

以下示例使用异常消息框来显示对排除故障或调试有帮助的其他信息。

try
{
    // Do something that you don't expect to generate an exception.
    throw new ApplicationException("Failed to connect to the server.");
}
catch (ApplicationException ex)
{
    string str = "An unexpected error occurred. Please call Helpdesk.";
    ApplicationException exTop = new ApplicationException(str, ex);
    exTop.Source = this.Text;

    // Information in the Data property of an exception that has a name
    // beginning with "HelpLink.Advanced" is shown when the user
    // clicks the Advanced Information button of the exception message
    // box dialog box.
    exTop.Data.Add("AdvancedInformation.FileName", "application.dll");
    exTop.Data.Add("AdvancedInformation.FilePosition", "line 355");
    exTop.Data.Add("AdvancedInformation.UserContext", "single user mode");

    // Show the exception message box with additional information that 
    // is helpful when a user calls technical support.
    ExceptionMessageBox box = new ExceptionMessageBox(exTop);

    box.Show(this);
}
Try
    ' Do something that you don't expect to generate an exception.
    Throw New ApplicationException("Failed to connect to the server.")
Catch ex As ApplicationException
    Dim str As String = "An unexpected error occurred. Please call Helpdesk."
    Dim exTop As ApplicationException = New ApplicationException(str, ex)
    exTop.Source = Me.Text

    ' Information in the Data property of an exception that has a name
    ' beginning with "HelpLink.Advanced" is shown when the user
    ' clicks the Advanced Information button of the exception message
    ' box dialog box.
    exTop.Data.Add("AdvancedInformation.FileName", "application.dll")
    exTop.Data.Add("AdvancedInformation.FilePosition", "line 355")
    exTop.Data.Add("AdvancedInformation.UserContext", "single user mode")

    ' Show the exception message box with additional information that 
    ' is helpful when a user calls technical support.
    Dim box As ExceptionMessageBox = New ExceptionMessageBox(exTop)

    box.Show(Me)

End Try

构造函数

ExceptionMessageBox()

使用默认属性创建 ExceptionMessageBox 的实例。

ExceptionMessageBox(Exception)

通过使用来自指定 ExceptionMessageBox 的信息创建 Exception 的实例。

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons)

通过使用来自指定 ExceptionMessageBox 的信息以及通过指定要在消息框中显示的按钮,创建 Exception 的实例。

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol)

通过使用来自指定 ExceptionMessageBox 的信息以及通过指定要在消息框中显示的按钮和符号,创建 Exception 的实例。

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton)

通过使用来自指定 ExceptionMessageBox 的信息以及通过指定要在异常消息框中显示的按钮、符号和默认按钮,创建 Exception 的实例。 .

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton, ExceptionMessageBoxOptions)

通过使用来自指定 ExceptionMessageBox 的信息以及通过指定要在异常消息框中显示的按钮、符号、默认按钮和其他属性,创建 Exception 的实例。

ExceptionMessageBox(String)

使用提供的顶级错误消息文本创建 ExceptionMessageBox 的实例。

ExceptionMessageBox(String, String)

创建一个实例 ExceptionMessageBox ,其中包含提供的顶级错误消息文本和异常消息框的对话框标题。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons)

创建一个实例 ExceptionMessageBox ,其中包含提供的顶级错误消息文本和异常消息框的对话框标题。 该方法还指定要在异常消息框中显示的按钮。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol)

使用提供的顶级错误消息文本以及异常消息框的对话框标题创建 ExceptionMessageBox 的实例。 该方法还指定要在异常消息框中显示的按钮和符号。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton)

使用提供的顶级错误消息文本以及消息框的对话框标题创建 ExceptionMessageBox 的实例。 该方法还指定要在异常消息框中显示的按钮、符号和默认按钮。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton, ExceptionMessageBoxOptions)

使用提供的顶级错误消息文本以及消息框的对话框标题创建 ExceptionMessageBox 的实例。 该方法还指定要在异常消息框中显示的按钮、符号、默认按钮和对话框选项。

属性

AbortButtonText

获取 中止 按钮的默认文本。

Beep

指定在显示消息时是否播放可听到的声音。

Buttons

获取或设置要在消息框中显示的按钮。

CancelButtonText

获取 “取消 ”按钮的默认文本。

Caption

获取或设置异常消息框的对话框标题。

CheckBoxRegistryKey

设置打开的 RegistryKey,它在 ShowCheckBoxtrue 时控制在异常消息框上显示的复选框。

CheckBoxRegistryMeansDoNotShowDialog

确定 CheckBoxRegistryKeyCheckBoxRegistryValue 指定的注册表值内容是否指示以前的用户决定不查看此消息。

CheckBoxRegistryValue

或者或设置注册表值名称,它在 ShowCheckBoxtrue 时控制异常消息框上的复选框。

CheckBoxText

或者或设置在 ShowCheckBoxtrue 时要在异常消息框上的复选框中显示的文本。

CustomDialogResult

获取所单击的自定义文本对话框按钮。

CustomSymbol

获取或设置要用作异常消息框上的符号的自定义位图。

Data

获取将存储与顶级消息相关联的帮助链接和高级信息的 IDictionary 接口。

DefaultButton

获取或设置消息框上的默认按钮。

DefaultDialogResult

获取或设置当用户以前已经指出不再显示给定的消息时,Show(IWin32Window) 方法的返回值。

FailButtonText

获取 “失败 ”按钮的默认文本。

Font

获取或设置用于消息框中的字体。

HelpLink

获取或设置指向与顶级消息相关联的帮助文件或帮助网页的链接。

IgnoreButtonText

获取 “忽略 ”按钮的默认文本。

InnerException

获取或设置与较低级别消息相关联的 Exception 实例。

IsCheckBoxChecked

指定在 ShowCheckBoxtrue 时是否选中复选框。

Message

获取或设置包含要显示的消息的 Exception

MessageLevelDefault

获取或设置要在消息框中显示的消息级别的数目。

NoButtonText

获取 “否 ”按钮的默认文本

OKButtonText

获取 “确定 ”按钮的默认文本

Options

获取或设置消息框的其他显示选项

RetryButtonText

获取 “重试 ”按钮的默认文本。

ShowCheckBox

指定是否在异常消息框中显示复选框。

ShowToolBar

指定是否在异常消息框上显示命令按钮工具栏。

Symbol

获取或设置要在异常消息框中显示的符号。

Text

获取或设置要在异常消息框中显示的顶级消息的文本

UseOwnerFont

指定是否检索所有者窗口的字体并将其用作异常消息框的字体。

YesButtonText

获取 “是 ”按钮的默认文本

方法

GetMessageText(Exception)

返回在异常消息框中显示异常时,用户可以复制到剪贴板的字符串。

SetButtonText(String)

设置当异常消息框中只显示一个按钮时自定义文本按钮的文本。

SetButtonText(String, String)

设置当异常消息框中只显示两个按钮时自定义文本按钮的文本。

SetButtonText(String, String, String)

设置当异常消息框中只显示三个按钮时自定义文本按钮的文本。

SetButtonText(String, String, String, String)

设置当异常消息框中只显示四个按钮时自定义文本按钮的文本。

SetButtonText(String, String, String, String, String)

设置当异常消息框中只显示五个按钮时自定义文本按钮的文本。

Show(IntPtr, String, String, String, String, String, String, String)

显示异常消息框。 标识为仅供参考。 不支持。 不保证以后的兼容性。

Show(IWin32Window)

将异常消息框显示为在父窗口上居中的模式对话框。

事件

OnCopyToClipboard

在将异常消息文本从消息框复制到剪贴板时发生。

适用于