语言

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, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton, ExceptionMessageBoxOptions)

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

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton)

通过利用指定Exception信息创建实例ExceptionMessageBox,并指定异常消息框中显示的按钮、符号和默认按钮。 。

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol)

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

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons)

通过使用指定Exception信息并指定消息框中显示的按钮,创建一个ExceptionMessageBox实例。

ExceptionMessageBox(Exception)

利用指定Exception信息创建 的ExceptionMessageBox实例。

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

创建 ExceptionMessageBox 一个实例,包含提供的顶层错误信息文本和消息框的对话框说明。 该方法还指定了在异常消息框中显示的按钮、符号、默认按钮和对话框选项。

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

创建 ExceptionMessageBox 一个实例,包含提供的顶层错误信息文本和消息框的对话框说明。 该方法还指定了在例外消息框中显示的按钮、符号和默认按钮。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol)

创建 ExceptionMessageBox 一个实例,包含提供的顶层错误消息文本和异常消息框的对话框说明。 该方法还指定了在异常消息框中显示的按钮和符号。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons)

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

ExceptionMessageBox(String, String)

创建 ExceptionMessageBox 一个实例,包含提供的顶层错误消息文本和例外消息框的对话框标题。

ExceptionMessageBox(String)

创建 ExceptionMessageBox 一个实例,包含提供的顶层错误消息文本。

属性

名称 说明
AbortButtonText

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

Beep

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

Buttons

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

CancelButtonText

会看到 取消 按钮的默认文本。

Caption

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

CheckBoxRegistryKey

设置一个已打开RegistryKey的,控制当 为 true时异常消息框ShowCheckBox上显示的复选框。

CheckBoxRegistryMeansDoNotShowDialog

确定注册表值内容是否由指定 CheckBoxRegistryKey ,表示 CheckBoxRegistryValue 用户之前决定不查看此消息。

CheckBoxRegistryValue

获取或设置注册表值名称,当 是 true时,控制异常消息框ShowCheckBox上的复选框。

CheckBoxText

当 ShowCheckBox 是 true时,获取或设置文本显示在例外消息框的复选框中。

CustomDialogResult

点击了自定义文本对话框按钮。

CustomSymbol

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

Data

获得 IDictionary 存储帮助链接和与顶层消息相关的高级信息的界面。

DefaultButton

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

DefaultDialogResult

当用户之前表示不再显示某条消息时,它会接收或设置方法返回的 Show(IWin32Window) 值。

FailButtonText

会获得 失败 按钮的默认文本。

Font

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

HelpLink

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

IgnoreButtonText

它会看到 “忽略 ”按钮的默认文本。

InnerException

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

IsCheckBoxChecked

指定当 时true是否选择复选框。ShowCheckBox

Message

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

MessageLevelDefault

获取或设置消息框中显示的消息等级数量。

NoButtonText

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

OKButtonText

获取 确认 按钮的默认文本

Options

获取或设置消息框的各种显示选项

RetryButtonText

会获得重 试 按钮的默认文本。

ShowCheckBox

指定是否在例外消息框中显示复选框。

ShowToolBar

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

Symbol

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

Text

获取或设置顶层消息的文本显示在例外消息框中

UseOwnerFont

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

YesButtonText

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

方法

名称 说明
GetMessageText(Exception)

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

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

当例外消息框中仅显示五个按钮时,设置自定义文本按钮的文本。

SetButtonText(String, String, String, String)

当例外消息框中仅显示四个按钮时,设置自定义文本按钮的文本。

SetButtonText(String, String, String)

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

SetButtonText(String, String)

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

SetButtonText(String)

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

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

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

Show(IWin32Window)

将异常消息框显示为位于父窗口中心的模态对话框。

活动

名称 说明
OnCopyToClipboard

当例外消息文本从消息框复制到剪贴板时,会发生这种情况。

适用于