System.Runtime.CompilerServices.ContractHelper.RaiseContractFailedEvent Method

Used by the binary rewriter to activate the default failure behavior.

Syntax

[System.Diagnostics.DebuggerNonUserCode]
[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.MayFail)]
public static string RaiseContractFailedEvent (System.Diagnostics.Contracts.ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException)

Parameters

failureKind
One of the enumeration values that specifies the type of failure.
userMessage
Additional user information.
conditionText
The description of the condition that caused the failure.
innerException
The inner exception that caused the current exception.

Returns

A null reference (Nothing in Visual Basic) if the event was handled and should not trigger a failure; otherwise, returns the localized failure message.

Remarks

The binary rewriter calls this method to notify listeners about a contract failure. The ContractHelper.RaiseContractFailedEvent(System.Diagnostics.Contracts.ContractFailureKind, string, string, Exception) method does not perform the failure behavior (an assert or throw) itself. If the failure is handled by the listeners, the method returns null. If the failure is not handled by the listeners, a localized failure message is returned.

Requirements

Namespace: System.Runtime.CompilerServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0