Type.IsSecuritySafeCritical Type.IsSecuritySafeCritical Type.IsSecuritySafeCritical Type.IsSecuritySafeCritical Property


获取一个值,该值指示当前类型在当前信任级别上是否是安全可靠关键的;即它是否可以执行关键操作并可以由透明代码访问。Gets a value that indicates whether the current type is security-safe-critical at the current trust level; that is, whether it can perform critical operations and can be accessed by transparent code.

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


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


IsSecurityCriticalIsSecuritySafeCritical,和IsSecurityTransparent属性报告在其当前的信任级别,由公共语言运行时 (CLR) 类型的透明度级别。The 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.