Specifies the permitted use of the System.Reflection and System.Reflection.Emit namespaces.
This enumeration is used by the System.Security.Permissions.ReflectionPermission and System.Security.Permissions.ReflectionPermissionAttribute classes. If no System.Security.Permissions.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.
Because System.Security.Permissions.ReflectionPermission can provide access to private class members, we recommend that you grant System.Security.Permissions.ReflectionPermission to Internet code only with the ReflectionPermissionFlag.RestrictedMemberAccess flag, and not with any other flags.
The ReflectionPermissionFlag.RestrictedMemberAccess flag is introduced in the net_v20sp1_short. To use this flag, your application should target the net_v35_long or later.
ReflectionPermissionFlag.AllFlags does not include the ReflectionPermissionFlag.RestrictedMemberAccess flag. To get a mask that includes all flags in this enumeration, you must use the combination of ReflectionPermissionFlag.AllFlags with ReflectionPermissionFlag.RestrictedMemberAccess.
Starting with the net_v20sp1_short, the ReflectionPermissionFlag.ReflectionEmit flag is no longer required to emit code, unless debug symbols are emitted. To use this feature, your application should target the net_v35_short or later.
Starting with the dnprdnlong, the ReflectionPermissionFlag.TypeInformation flag is no longer required to reflect on nonpublic types and members; the flag has been marked obsolete.
Member Name | Description |
---|---|
AllFlags |
TypeInformation, MemberAccess, and ReflectionEmit are set. ReflectionPermissionFlag.AllFlags does not include ReflectionPermissionFlag.RestrictedMemberAccess. |
MemberAccess |
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 |
Enumeration of types and members is allowed. Invocation operations are allowed on visible types and members. |
ReflectionEmit |
Emitting debug symbols is allowed. Beginning with the net_v20sp1_long, this flag is no longer required to emit code. |
RestrictedMemberAccess |
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. This flag is new in the net_v20sp1_short. |
TypeInformation |
This flag is obsolete. No flags are necessary to enumerate types and members and to examine their metadata. Use ReflectionPermissionFlag.NoFlags instead. |