ReliabilityContractAttribute 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
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 特性来记录程序集的可靠性级别。
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 ,通过记录特定代码段的可靠性级别来定义可靠性协定。
Reliability |
已过时.
使用指定 Consistency 保证和 Cer 值初始化 ReliabilityContractAttribute 类的新实例。 |
Cer |
已过时.
获取当在受约束的执行区域 (CER) 下调用时用来确定方法、类型或程序集的行为的值。 |
Consistency |
已过时.
获取 Consistency 可靠性协定的值。 |
Type |
已过时.
在派生类中实现时,获取此 Attribute 的唯一标识符。 (继承自 Attribute) |
Equals(Object) |
已过时.
返回一个值,该值指示此实例是否与指定的对象相等。 (继承自 Attribute) |
Get |
已过时.
返回此实例的哈希代码。 (继承自 Attribute) |
Get |
已过时.
获取当前实例的 Type。 (继承自 Object) |
Is |
已过时.
在派生类中重写时,指示此实例的值是否是派生类的默认值。 (继承自 Attribute) |
Match(Object) |
已过时.
当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 (继承自 Attribute) |
Memberwise |
已过时.
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
已过时.
返回表示当前对象的字符串。 (继承自 Object) |
_Attribute. |
已过时.
将一组名称映射为对应的一组调度标识符。 (继承自 Attribute) |
_Attribute. |
已过时.
检索对象的类型信息,然后可以使用该信息获取接口的类型信息。 (继承自 Attribute) |
_Attribute. |
已过时.
检索对象提供的类型信息接口的数量(0 或 1)。 (继承自 Attribute) |
_Attribute. |
已过时.
提供对某一对象公开的属性和方法的访问。 (继承自 Attribute) |
产品 | 版本 (已过时) |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1 (5, 6, 7, 8, 9) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- Consistency
- Cer
- Constrained Execution Regions(受约束的执行区域)
- 可靠性最佳做法