Emits or displays a message and a stack trace for an assertion that always fails.
Namespace:
System.Diagnostics
Assembly:
System (in System.dll)
Visual Basic (Declaration)
Public Overrides Sub Fail ( _
message As String _
)
Dim instance As DefaultTraceListener
Dim message As String
instance.Fail(message)
public override void Fail(
string message
)
public:
virtual void Fail(
String^ message
) override
public override function Fail(
message : String
)
By default, this method sends the message parameter and a stack trace to a message box (when the application runs in user-interface mode) and to the DefaultTraceListener instance.
The following code example writes an error message to a DefaultTraceListener using the Fail(String) method. The method also writes the message to the console if a user interface is not available.
' Report that the required argument is not present.
Const ENTER_PARAM As String = "Enter the number of " & _
"possibilities as a command line argument."
defaultListener.Fail(ENTER_PARAM)
If Not defaultListener.AssertUiEnabled Then
Console.WriteLine(ENTER_PARAM)
End If
// Report that the required argument is not present.
const string ENTER_PARAM = "Enter the number of " +
"possibilities as a command line argument.";
defaultListener.Fail(ENTER_PARAM);
if (!defaultListener.AssertUiEnabled)
{
Console.WriteLine(ENTER_PARAM);
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Supported in: 3.5
XNA Framework
Supported in: 3.0, 2.0, 1.0
Reference