ContractHelper.RaiseContractFailedEvent Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Used by the binary rewriter to activate the default failure behavior.
Namespace: System.Diagnostics.Contracts.Internal
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<DebuggerNonUserCodeAttribute> _
Public Shared Function RaiseContractFailedEvent ( _
failureKind As ContractFailureKind, _
userMessage As String, _
conditionText As String, _
innerException As Exception _
) As String
[DebuggerNonUserCodeAttribute]
public static string RaiseContractFailedEvent(
ContractFailureKind failureKind,
string userMessage,
string conditionText,
Exception innerException
)
Parameters
- failureKind
Type: System.Diagnostics.Contracts.ContractFailureKind
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.
Exceptions
Exception | Condition |
---|---|
ArgumentException | failureKind is not a valid ContractFailureKind value. |
Remarks
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 nulla null reference (Nothing in Visual Basic). If the failure is not handled by the listeners, a localized failure message is returned.
Version Information
Silverlight
Supported in: 5, 4
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.