ReflectionPermissionFlag ReflectionPermissionFlag ReflectionPermissionFlag ReflectionPermissionFlag Enum

定义

指定 System.ReflectionSystem.Reflection.Emit 命名空间的允许用法。Specifies the permitted use of the System.Reflection and System.Reflection.Emit namespaces.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class ReflectionPermissionFlag
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum ReflectionPermissionFlag
type ReflectionPermissionFlag = 
Public Enum ReflectionPermissionFlag
继承
ReflectionPermissionFlagReflectionPermissionFlagReflectionPermissionFlagReflectionPermissionFlag
属性

字段

AllFlags AllFlags AllFlags AllFlags 7

TypeInformationMemberAccessReflectionEmit 进行了设置。TypeInformation , MemberAccess, and ReflectionEmit are set. AllFlags 不包括 RestrictedMemberAccessAllFlags does not include RestrictedMemberAccess.

MemberAccess MemberAccess MemberAccess MemberAccess 2

无论授予集是什么,都允许在所有成员上进行调用操作。Invocation operations on all members are allowed, regardless of grant set. 如果未设置此标志,则只允许在可见成员上进行调用操作。If this flag is not set, invocation operations are allowed only on visible members.

NoFlags NoFlags NoFlags NoFlags 0

允许对类型和成员进行枚举。Enumeration of types and members is allowed. 允许在可见类型和成员上进行调用操作。Invocation operations are allowed on visible types and members.

ReflectionEmit ReflectionEmit ReflectionEmit ReflectionEmit 4

允许发出调试符号。Emitting debug symbols is allowed. .NET Framework 2.0 Service Pack 1.NET Framework 2.0 Service Pack 1 开始,发出代码时不再需要此标志。Beginning with the .NET Framework 2.0 Service Pack 1.NET Framework 2.0 Service Pack 1, this flag is no longer required to emit code.

RestrictedMemberAccess RestrictedMemberAccess RestrictedMemberAccess RestrictedMemberAccess 8

为部分受信任代码提供了受限成员访问。Restricted member access is provided for partially trusted code. 部分受信任代码可以访问非公共类型和成员,但前提条件是部分受信任代码的授予集包括程序集(该程序集包含要访问的非公共类型和成员)的授予集内的所有权限。Partially trusted code can access nonpublic types and members, but only if the grant set of the partially trusted code includes all permissions in the grant set of the assembly that contains the nonpublic types and members being accessed. 此标志在 .NET Framework 2.0 SP1.NET Framework 2.0 SP1 中是新增标志。This flag is new in the .NET Framework 2.0 SP1.NET Framework 2.0 SP1.

TypeInformation TypeInformation TypeInformation TypeInformation 1

此标志已过时。This flag is obsolete. 枚举类型和成员以及检验它们的元数据时不需要任何标志。No flags are necessary to enumerate types and members and to examine their metadata. 请改用 NoFlagsUse NoFlags instead.

示例

下面的示例演示如何使用RestrictedMemberAccess枚举初始化的新实例RestrictedMemberAccess表示有权执行受限的成员访问权限的类。The following example shows how to use the RestrictedMemberAccess enumeration to initialize a new instance of the RestrictedMemberAccess class that represents the right to perform restricted member access. 此示例摘自一个更大的示例为提供AllFlags类。This example is part of a larger example that is provided for the AllFlags class.

有关演示如何将 restrictedmemberaccess 添加标志用于 Internet 代码的示例,请参阅演练:在部分信任方案中发出代码For an example that shows how to use the RestrictedMemberAccess flag with Internet code, see Walkthrough: Emitting Code in Partial Trust Scenarios.

ReflectionPermission restrictedMemberAccessPerm = new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess);
Dim restrictedMemberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess)

注解

此枚举由ReflectionPermissionReflectionPermissionAttribute类。This enumeration is used by the ReflectionPermission and ReflectionPermissionAttribute classes. 如果没有ReflectionPermission授予,反射允许所有类型和成员,但都允许仅在可见类型和成员上调用操作。If no ReflectionPermission is granted, reflection is allowed on all types and members, but invocation operations are allowed only on visible types and members. 有关详细信息,请参阅反射的安全注意事项For more information, see Security Considerations for Reflection.

注意

因为ReflectionPermission可以提供访问私有类成员,我们建议你授予ReflectionPermissionInternet 代码只能与 restrictedmemberaccess 添加标志,而不是与任何其他标志。Because ReflectionPermission can provide access to private class members, we recommend that you grant ReflectionPermission to Internet code only with the RestrictedMemberAccess flag, and not with any other flags.

中引入 restrictedmemberaccess 添加标志.NET Framework 2.0 SP1.NET Framework 2.0 SP1The RestrictedMemberAccess flag is introduced in the .NET Framework 2.0 SP1.NET Framework 2.0 SP1. 若要使用此标志,你的应用程序应面向 .NET Framework 3.5.NET Framework 3.5或更高版本。To use this flag, your application should target the .NET Framework 3.5.NET Framework 3.5 or later.

重要

AllFlags 不包括 restrictedmemberaccess 添加标志。AllFlags does not include the RestrictedMemberAccess flag. 若要获取此枚举中包括所有标志的掩码,您必须使用带有 restrictedmemberaccess 添加 AllFlags 的组合。To get a mask that includes all flags in this enumeration, you must use the combination of AllFlags with RestrictedMemberAccess.

从开始.NET Framework 2.0 SP1.NET Framework 2.0 SP1,ReflectionEmit 标志不再需要发出的代码,除非发出调试符号。Starting with the .NET Framework 2.0 SP1.NET Framework 2.0 SP1, the ReflectionEmit flag is no longer required to emit code, unless debug symbols are emitted. 若要使用此功能,你的应用程序应面向.NET Framework 3.5.NET Framework 3.5或更高版本。To use this feature, your application should target the .NET Framework 3.5.NET Framework 3.5 or later.

从开始.NET Framework 2.0.NET Framework 2.0,不再要求 TypeInformation 标志,以反映非公共类型和成员; 标志已标记为已过时。Starting with the .NET Framework 2.0.NET Framework 2.0, the TypeInformation flag is no longer required to reflect on nonpublic types and members; the flag has been marked obsolete.

适用于

另请参阅