ReflectionPermissionFlag Enumeration
Collapse the table of content
Expand the table of content

ReflectionPermissionFlag Enumeration

Specifies the permitted use of the System.Reflection and System.Reflection.Emit namespaces.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

public enum ReflectionPermissionFlag
/** @attribute SerializableAttribute() */ 
/** @attribute FlagsAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum ReflectionPermissionFlag
public enum ReflectionPermissionFlag

 Member nameDescription
AllFlagsTypeInformation, MemberAccess, and ReflectionEmit are set. AllFlags does not include RestrictedMemberAccess
MemberAccessInvocation operations on all members are allowed, regardless of grant set. If this flag is not set, invocation operations are allowed only on visible members. 
NoFlagsEnumeration of types and members is allowed. Invocation operations are allowed on visible types and members. 
ReflectionEmitEmitting debug symbols is allowed. Beginning with the , this flag is no longer required to emit code. 
TypeInformationThis flag is obsolete. No flags are necessary to enumerate types and members and to examine their metadata. Use NoFlags instead. 

This enumeration is used by the ReflectionPermission and ReflectionPermissionAttribute classes. 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.

Caution noteCaution:

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.

The RestrictedMemberAccess flag is introduced in the . To use this flag, your application should target the . For more information, see The .NET Framework 3.5 Architecture.


AllFlags does not include the RestrictedMemberAccess flag. To get a mask that includes all flags in this enumeration, you must use the combination of AllFlags with RestrictedMemberAccess.

Starting with the , the ReflectionEmit flag is no longer required to emit code, unless debug symbols are emitted. (See Security Issues in Reflection Emit.) To use this feature, your application should target the .

Starting with the .NET Framework 2.0, the TypeInformation flag is no longer required to reflect on nonpublic types and members; the flag has been marked obsolete.

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. This example is part of a larger example that is provided for the ReflectionPermission class.

For an example that shows how to use the RestrictedMemberAccess flag with Internet code, see Walkthrough: Emitting Code in Partial Trust Scenarios.

ReflectionPermission reflectionPerm2 = new ReflectionPermission(ReflectionPermissionFlag.ReflectionEmit);

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

© 2015 Microsoft