System.Diagnostics.Trace.Fail Method

Emits the specified error message.

Syntax

[System.Diagnostics.Conditional("TRACE")]
public static void Fail (string message)

Parameters

message
A message to emit.

Remarks

The default behavior for the default trace listener is to output the message parameter to a message box when the application runs in user-interface mode, and to the System.Diagnostics.TraceListener instances in the Trace.Listeners collection.

Note:

The display of the message box is dependent on the presence of the System.Diagnostics.DefaultTraceListener. If the System.Diagnostics.DefaultTraceListener is not in the Trace.Listeners collection, the message box is not displayed. The System.Diagnostics.DefaultTraceListener can be removed by the <clear> Element for <listeners> for <trace>, the <remove> Element for <listeners> for <trace>, or by calling the TraceListenerCollection.Clear method on the Trace.Listeners property (System.Diagnostics.Trace.Listeners.Clear()).

You can customize this behavior by adding a System.Diagnostics.TraceListener to, or by removing one from, the Trace.Listeners collection.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0