MethodBase.IsSecurityTransparent 属性


获取一个值,该值指示当前方法或构造函数在当前信任级别上是透明的,因此无法执行关键操作。Gets a value that indicates whether the current method or constructor is transparent at the current trust level, and therefore cannot perform critical operations.

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



如果方法或构造函数在当前信任级别上是安全透明的,则为 true;否则为 falsetrue if the method or constructor is security-transparent at the current trust level; otherwise, false.


如果此属性返回 true ,则 IsSecurityCriticalIsSecuritySafeCritical 属性返回 falseIf this property returns true, the IsSecurityCritical and IsSecuritySafeCritical properties return false.

IsSecurityCriticalIsSecuritySafeCriticalIsSecurityTransparent 属性在其当前信任级别报告方法或构造函数的透明度级别,由公共语言运行时 (CLR) 确定。The IsSecurityCritical, IsSecuritySafeCritical, and IsSecurityTransparent properties report the transparency level of the method or constructor at its current trust level, as determined by the common language runtime (CLR). 使用这些属性比检查程序集及其类型和成员的安全批注、检查当前的信任级别以及尝试复制运行时的规则要简单得多。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), 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.