Type.IsSecurityCritical Type.IsSecurityCritical Type.IsSecurityCritical Type.IsSecurityCritical Property

定义

获取一个值,该值指示当前的类型在当前信任级别上是安全关键的还是安全可靠关键的,并因此可以执行关键操作。Gets a value that indicates whether the current type is security-critical or security-safe-critical at the current trust level, and therefore can perform critical operations.

public:
 virtual property bool IsSecurityCritical { bool get(); };
public virtual bool IsSecurityCritical { get; }
member this.IsSecurityCritical : bool
Public Overridable ReadOnly Property IsSecurityCritical As Boolean

属性值

如果当前类型在当前信任级别上是安全关键的或安全可靠关键的,则为 true;如果它是透明的,则为 falsetrue if the current type is security-critical or security-safe-critical at the current trust level; false if it is transparent.

注解

IsSecurityCritical、和属性IsSecurityTransparent按公共语言运行时(CLR)确定的,在其当前信任级别上报告类型的透明度级别。 IsSecuritySafeCriticalThe IsSecurityCritical, IsSecuritySafeCritical, and IsSecurityTransparent properties report the transparency level of the type at its current trust level, as determined by the common language runtime (CLR). 下表显示了这些属性的组合:The combinations of these properties are shown in the following table:

安全级别Security level IsSecurityCriticalIsSecurityCritical IsSecurityCriticalIsSecuritySafeCritical IsSecurityTransparentIsSecurityTransparent
严重Critical true false false
安全关键Safe critical true true false
透明Transparent false false true

使用这些属性比检查程序集及其类型的安全批注、检查当前的信任级别,以及尝试复制运行时的规则要简单得多。Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules.

重要

对于部分信任的程序集,此属性的值取决于程序集的当前信任级别。For partial-trust assemblies, the value of this property depends on the current trust level of the assembly. 如果将程序集加载到部分受信任的应用程序域中(例如,在沙盒应用程序域中),则运行时将忽略程序集的安全注释。If the assembly is loaded into a partially trusted application domain (for example, into a sandboxed application domain), then the runtime ignores the security annotations of the assembly. 程序集及其所有类型都被视为透明。The assembly and all its types are treated as transparent. 仅当程序集加载到完全受信任的应用程序域中时(例如,在桌面应用程序的默认应用程序域中),运行时才会注意到部分信任程序集的安全注释。The runtime pays attention to the security annotations of a partial-trust assembly only when that assembly is loaded into a fully trusted application domain (for example, into the default application domain of a desktop application). 相反,受信任的程序集(即安装在全局程序集缓存中的强名称程序集)始终以完全信任方式加载,而不考虑应用程序域的信任级别,因此,其当前信任级别始终是完全受信任的。By contrast, a trusted assembly (that is, a strong-named assembly that is installed in the global assembly cache) is always loaded with full trust regardless of the trust level of the application domain, so its current trust level is always fully trusted. 您可以使用Assembly.IsFullyTrustedAppDomain.IsFullyTrusted属性来确定程序集和应用程序域的当前信任级别。You can determine the current trust levels of assemblies and application domains by using the Assembly.IsFullyTrusted and AppDomain.IsFullyTrusted properties.

有关反射和透明度的详细信息,请参阅反射的安全注意事项For more information about reflection and transparency, see Security Considerations for Reflection. 有关透明度的信息,请参阅安全更改For information about transparency, see Security Changes.

适用于

另请参阅