FieldInfo.IsSecuritySafeCritical 属性


获取一个值,该值指示当前字段在当前信任级别上是否是安全可靠关键的。Gets a value that indicates whether the current field is security-safe-critical at the current trust level.

 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 field 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 field 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 and members, 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.IsFullyTrusted AppDomain.IsFullyTrustedYou 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.