ContractHelper.RaiseContractFailedEvent(ContractFailureKind, String, String, Exception) 方法
定义
由二进制重写工具用来激活默认失败行为。Used by the binary rewriter to activate the default failure behavior.
public:
static System::String ^ RaiseContractFailedEvent(System::Diagnostics::Contracts::ContractFailureKind failureKind, System::String ^ userMessage, System::String ^ conditionText, Exception ^ innerException);
public static string RaiseContractFailedEvent (System.Diagnostics.Contracts.ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException);
public static string? RaiseContractFailedEvent (System.Diagnostics.Contracts.ContractFailureKind failureKind, string? userMessage, string? conditionText, Exception? innerException);
static member RaiseContractFailedEvent : System.Diagnostics.Contracts.ContractFailureKind * string * string * Exception -> string
Public Shared Function RaiseContractFailedEvent (failureKind As ContractFailureKind, userMessage As String, conditionText As String, innerException As Exception) As String
参数
- failureKind
- ContractFailureKind
指定故障类型的枚举值之一。One of the enumeration values that specifies the type of failure.
- userMessage
- String
其他用户信息。Additional user information.
- conditionText
- String
对导致失败的条件的说明。The description of the condition that caused the failure.
- innerException
- Exception
导致当前异常的内部异常。The inner exception that caused the current exception.
返回
如果事件已经过处理且不应触发失败,则为空引用(在 Visual Basic 中为 Nothing);否则返回本地化的失败消息。A null reference (Nothing in Visual Basic) if the event was handled and should not trigger a failure; otherwise, returns the localized failure message.
例外
failureKind 不是有效的 ContractFailureKind 值。failureKind is not a valid ContractFailureKind value.
注解
二进制重写程序调用此方法以通知侦听器有关协定失败的信息。The binary rewriter calls this method to notify listeners about a contract failure. RaiseContractFailedEvent方法不 (断言或抛出) 本身来执行失败行为。The RaiseContractFailedEvent method does not perform the failure behavior (an assert or throw) itself. 如果故障由侦听器处理,则该方法返回 null 。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.