可靠性Reliability

在服务器环境(如 SQL Server)中执行的代码防止发生异步异常,这一点非常重要。It is important that code executing in server environments such as SQL Server protect against asynchronous exceptions. 文本所讨论的可靠性并不是针对 SQL Server 而言,而是针对为在 .NET Framework 版本 2.0 环境中执行的任何主机编写可靠代码而言。Reliability, as discussed here, is not specific to SQL Server but to writing reliable code for any host executing in a .NET Framework version 2.0 environment. SQL Server 是第一个广泛使用版本 2.0 的新可靠性功能的服务,所以将其作为示例。However, SQL Server is the first service making extensive use of the new reliability features of version 2.0, so it is used as an example.

在 SQL Server 中运行的代码必须使用与其他服务器环境相比更严格的可靠性准则。Code running in SQL Server must deal with more stringent reliability guidelines than other server environments. 这是因为 SQL Server 在资源消耗方面的稳定操作。This is due to SQL Server’s steady operation at the edge of resource consumption. OutOfMemoryExceptionThreadAbortException 异常在 SQL Server 环境中比较常见。OutOfMemoryException and ThreadAbortException exceptions are not uncommon in the SQL Server environment. 这些准则通常较少强调可靠性,更多专注于允许完全信任的托管代码面对 AppDomain 级别的回收温和地失败,这是服务器维持一致性和可用性的主要方法。These guidelines in general are focused less on reliability and more on allowing fully trusted managed code to fail gracefully in the face of AppDomain-level recycling, which is the primary way the server maintains consistency and availability.

本节内容In This Section

SQL Server 编程和宿主保护特性SQL Server Programming and Host Protection Attributes
介绍 SQL Server 如何使用 HostProtectionAttribute 属性限制托管代码的执行。Describes how the HostProtectionAttribute attribute is used by SQL Server to restrict the execution of managed code.

可靠性最佳做法Reliability Best Practices
提供用于编写符合可靠性要求的代码的准则。Provides guidelines for writing code that meets reliability requirements.

受约束的执行区域Constrained Execution Regions
介绍受约束的执行区域 (CER) 的功能和行为。Describes the function and behavior of constrained execution regions (CERs).

参考Reference

HostProtectionAttribute

HostProtectionResource