ContractHelper::RaiseContractFailedEvent Method (ContractFailureKind, String^, String^, Exception^)

.NET Framework (current version)
 

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

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

public:
static String^ RaiseContractFailedEvent(
	ContractFailureKind failureKind,
	String^ userMessage,
	String^ conditionText,
	Exception^ innerException
)

Parameters

failureKind
Type: System.Diagnostics.Contracts::ContractFailureKind

One of the enumeration values that specifies the type of failure.

userMessage
Type: System::String^

Additional user information.

conditionText
Type: System::String^

The description of the condition that caused the failure.

innerException
Type: System::Exception^

The inner exception that caused the current exception.

Return Value

Type: System::String^

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

Exception Condition
ArgumentException

failureKind is not a valid ContractFailureKind value.

The binary rewriter calls this method to notify listeners about a contract failure. The RaiseContractFailedEvent 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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: