ExceptionMessageBox 類別
Displays a message box that can be customized with text, buttons, and symbols to improve the customer experience with a Microsoft Windows .NET Framework-based application.
命名空間: Microsoft.SqlServer.MessageBox
組件: Microsoft.ExceptionMessageBox (在 Microsoft.ExceptionMessageBox.dll 中)
語法
'宣告
<ComVisibleAttribute(False)> _
Public Class ExceptionMessageBox
'用途
Dim instance As ExceptionMessageBox
[ComVisibleAttribute(false)]
public class ExceptionMessageBox
[ComVisibleAttribute(false)]
public ref class ExceptionMessageBox
[<ComVisibleAttribute(false)>]
type ExceptionMessageBox = class end
public class ExceptionMessageBox
範例
This example displays the message box with an OK button.
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
This example uses the exception message box to show additional information that is helpful when troubleshooting or debugging.
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
繼承階層
System. . :: . .Object
Microsoft.SqlServer.MessageBox..::..ExceptionMessageBox
執行緒安全性
這個類型的任何公用static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員都可以是安全執行緒。