ExceptionMessageBox.Show 方法

定义

显示异常消息框。

重载

Show(IWin32Window)

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

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

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

Show(IWin32Window)

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

public:
 System::Windows::Forms::DialogResult Show(System::Windows::Forms::IWin32Window ^ owner);
public System.Windows.Forms.DialogResult Show (System.Windows.Forms.IWin32Window owner);
member this.Show : System.Windows.Forms.IWin32Window -> System.Windows.Forms.DialogResult
Public Function Show (owner As IWin32Window) As DialogResult

参数

owner
IWin32Window

异常消息框的父窗口。

返回

用户单击的按钮的 DialogResult

示例

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

注解

Custom何时ButtonsShow始终返回Cancel。 用于 CustomDialogResult 确定用户单击的按钮。

为某个 null 值提供 Owner时,异常消息框将显示在 Windows 任务栏上。 建议改为传递父窗口对象。

适用于

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

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

public:
 System::Windows::Forms::DialogResult Show(IntPtr hwnd, System::String ^ message, System::String ^ source, System::String ^ sourceAppName, System::String ^ sourceAppVersion, System::String ^ sourceModule, System::String ^ sourceMessageId, System::String ^ sourceLanguage);
public System.Windows.Forms.DialogResult Show (IntPtr hwnd, string message, string source, string sourceAppName, string sourceAppVersion, string sourceModule, string sourceMessageId, string sourceLanguage);
member this.Show : nativeint * string * string * string * string * string * string * string -> System.Windows.Forms.DialogResult
Public Function Show (hwnd As IntPtr, message As String, source As String, sourceAppName As String, sourceAppVersion As String, sourceModule As String, sourceMessageId As String, sourceLanguage As String) As DialogResult

参数

hwnd
IntPtr

nativeint

一个 System.IntPtr,这是对父窗口的控点。

message
String

一个字符串,该字符串包含与此实例相关联的异常的消息。

source
String

一个字符串,该字符串包含与此实例相关联的异常的源。

sourceAppName
String

一个字符串,该字符串包含源应用程序的名称。

sourceAppVersion
String

一个字符串,该字符串包含源应用程序版本。

sourceModule
String

一个字符串,该字符串包含源模块名称。

sourceMessageId
String

一个字符串,该字符串包含源消息 ID。

sourceLanguage
String

一个字符串,该字符串包含源语言。

返回

用户单击的按钮的 DialogResult

适用于