ReflectionPermissionFlag 枚举

定义

指定 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
继承
ReflectionPermissionFlag
属性

字段

AllFlags 7

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

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 0

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

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 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 1

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

示例

下面的示例演示如何使用 ReflectionPermissionFlag 枚举来初始化 ReflectionPermission 类的新实例,该类表示执行受限成员访问权限的权限。The following example shows how to use the ReflectionPermissionFlag enumeration to initialize a new instance of the ReflectionPermission class that represents the right to perform restricted member access. 此示例是为 ReflectionPermission 类提供的更大示例的一部分。This example is part of a larger example that is provided for the ReflectionPermission 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 可以提供对私有类成员的访问,因此我们建议你仅使用 RestrictedMemberAccess 标志向 Internet 代码授予 ReflectionPermission,而不是使用任何其他标志。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 SP1 中引入。The 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. 若要获取包含此枚举中的所有标志的掩码,你必须将 AllFlagsRestrictedMemberAccess结合使用。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.

适用于

另请参阅