ExceptionMessageBox 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
显示一个可自定义的消息框,包含文本、按钮和符号,以提升基于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
构造函数
属性
| 名称 | 说明 |
|---|---|
| AbortButtonText |
获取中 止 按钮的默认文本。 |
| Beep |
指定在显示消息时是否播放可听声音。 |
| Buttons |
获取或设置按钮显示在消息框中。 |
| CancelButtonText |
会看到 取消 按钮的默认文本。 |
| Caption |
获取或设置异常消息框的对话框标题。 |
| CheckBoxRegistryKey |
设置一个已打开RegistryKey的,控制当 为 |
| CheckBoxRegistryMeansDoNotShowDialog |
确定注册表值内容是否由指定 CheckBoxRegistryKey ,表示 CheckBoxRegistryValue 用户之前决定不查看此消息。 |
| CheckBoxRegistryValue |
获取或设置注册表值名称,当 是 |
| CheckBoxText |
当 ShowCheckBox 是 |
| CustomDialogResult |
点击了自定义文本对话框按钮。 |
| CustomSymbol |
获取或设置自定义位图,作为异常消息框上的符号。 |
| Data |
获得 IDictionary 存储帮助链接和与顶层消息相关的高级信息的界面。 |
| DefaultButton |
获取或设置消息框上的默认按钮。 |
| DefaultDialogResult |
当用户之前表示不再显示某条消息时,它会接收或设置方法返回的 Show(IWin32Window) 值。 |
| FailButtonText |
会获得 失败 按钮的默认文本。 |
| Font |
获取或设置消息框中使用的字体。 |
| HelpLink |
获取或设置与顶层消息关联的帮助文件或帮助网页的链接。 |
| IgnoreButtonText |
它会看到 “忽略 ”按钮的默认文本。 |
| InnerException |
获取或设置 Exception 与低级别消息相关的实例。 |
| IsCheckBoxChecked |
指定当 时 |
| 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 |
当例外消息文本从消息框复制到剪贴板时,会发生这种情况。 |