TypeBuilder.IsSecurityTransparent TypeBuilder.IsSecurityTransparent TypeBuilder.IsSecurityTransparent TypeBuilder.IsSecurityTransparent Property

定义

获取一个值,该值指示当前类型是否透明,且因此是否无法指定关键操作。Gets a value that indicates whether the current type is transparent, and therefore cannot perform critical operations.

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

属性值

如果此类型是安全-透明的,则为 true;否则为 falsetrue if the type is security-transparent; otherwise, false.

异常

当前动态类型不是通过调用 CreateType() 方法创建的。The current dynamic type has not been created by calling the CreateType() method.

注解

IsSecurityCritical、和属性IsSecurityTransparent报告由公共语言运行时(CLR)确定的类型的透明度级别。 IsSecuritySafeCriticalThe IsSecurityCritical, IsSecuritySafeCritical, and IsSecurityTransparent properties report the transparency level of the type, 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.

运行时开始计算程序集的透明度级别。The runtime begins evaluating transparency levels at the assembly. 例如,如果动态程序集是安全关键的,则类型上的批注将被忽略,并且所有类型都是安全关键的。For example, if the dynamic assembly is security-critical, annotations on types are ignored, and all types are security-critical.

默认情况下,动态程序集继承发出它的程序集的透明度。By default, a dynamic assembly inherits the transparency of the assembly that emits it. 您可以使用AppDomain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)AppDomain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, String, Boolean, IEnumerable<CustomAttributeBuilder>)AppDomain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>)方法重载,并指定安全特性来重写此默认值。You can override this default by using the AppDomain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>), AppDomain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, String, Boolean, IEnumerable<CustomAttributeBuilder>), or AppDomain.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>) method overload and specifying security attributes. 您无法通过执行此操作提升安全级别;也就是说,透明代码无法发出安全关键代码或安全可靠关键代码。You cannot elevate security levels by doing this; that is, transparent code cannot emit security-critical or security-safe-critical code. 创建动态程序集时必须指定属性,或在程序集保存到磁盘并重新加载后,它们才会生效。Attributes must be specified when the dynamic assembly is created, or they do not take effect until the assembly has been saved to disk and reloaded.

备注

默认继承限制为运行时的透明度计算。Default inheritance is limited to the runtime's evaluation of transparency. 没有属性应用于动态程序集。No attributes are applied to the dynamic assembly. 如果要添加安全属性,则必须自行应用这些属性。If you want to add security attributes, you must apply them yourself.

有关反射发出和透明度的详细信息,请参阅反射发出中的安全问题For more information about reflection emit and transparency, see Security Issues in Reflection Emit. 有关透明度的信息,请参阅安全更改For information about transparency, see Security Changes.

适用于

另请参阅