ReliabilityContractAttribute 类

定义

注意

The Constrained Execution Region (CER) feature is not supported.

定义某些代码的作者和依赖于这些代码的开发人员之间的可靠性协定。

public ref class ReliabilityContractAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Struct, Inherited=false)]
[System.Obsolete("The Constrained Execution Region (CER) feature is not supported.", DiagnosticId="SYSLIB0004", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class ReliabilityContractAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Struct, Inherited=false)]
public sealed class ReliabilityContractAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Struct, Inherited=false)>]
[<System.Obsolete("The Constrained Execution Region (CER) feature is not supported.", DiagnosticId="SYSLIB0004", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type ReliabilityContractAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Struct, Inherited=false)>]
type ReliabilityContractAttribute = class
    inherit Attribute
Public NotInheritable Class ReliabilityContractAttribute
Inherits Attribute
继承
ReliabilityContractAttribute
属性

示例

下面的代码示例演示如何使用 ReliabilityContractAttribute 特性来记录程序集的可靠性级别。

using namespace System;
using namespace System::Runtime::ConstrainedExecution;

[assembly:ReliabilityContractAttribute(
   Consistency::MayCorruptInstance, Cer::None)];
namespace ReliabilityLibrary
{
   class SomeClass {};
}
using System;
using System.Runtime.ConstrainedExecution;

[assembly:ReliabilityContractAttribute(
   Consistency.MayCorruptInstance, Cer.None)]
namespace ReliabilityLibrary
{
   class SomeClass {}
}
Imports System.Runtime.ConstrainedExecution

<assembly:ReliabilityContractAttribute( _ 
   Consistency.MayCorruptInstance, Cer.None)> 
Namespace ReliabilityLibrary
   Class SomeClass
   End Class
End Namespace

注解

属性 ReliabilityContractAttribute 提供了一种机制,用于记录代码,并指示在遇到可能导致不一致状态的异常情况时,可以做出哪种类型的可靠性保证。 在此上下文中,异常条件定义为公共语言运行时可以在运行时生成的异步异常,例如线程中止、内存不足情况和堆栈溢出。 可以将 特性应用于 ReliabilityContractAttribute 程序集、类型和方法。

将此属性与枚举结合使用 Consistency ,通过记录特定代码段的可靠性级别来定义可靠性协定。

构造函数

ReliabilityContractAttribute(Consistency, Cer)
已过时.

使用指定 Consistency 保证和 Cer 值初始化 ReliabilityContractAttribute 类的新实例。

属性

Cer
已过时.

获取当在受约束的执行区域 (CER) 下调用时用来确定方法、类型或程序集的行为的值。

ConsistencyGuarantee
已过时.

获取 Consistency 可靠性协定的值。

TypeId
已过时.

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)

方法

Equals(Object)
已过时.

返回一个值,该值指示此实例是否与指定的对象相等。

(继承自 Attribute)
GetHashCode()
已过时.

返回此实例的哈希代码。

(继承自 Attribute)
GetType()
已过时.

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()
已过时.

在派生类中重写时,指示此实例的值是否是派生类的默认值。

(继承自 Attribute)
Match(Object)
已过时.

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()
已过时.

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()
已过时.

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)
已过时.

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)
已过时.

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)
已过时.

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)
已过时.

提供对某一对象公开的属性和方法的访问。

(继承自 Attribute)

适用于

另请参阅