ReflectionPermissionFlag Enumeration

Specifies the permitted use of System.Reflection on members that are not visible.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

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

 Member nameDescription
AllFlagsTypeInformation, MemberAccess, and ReflectionEmit are set. 
MemberAccessInvocation of operations on all type members is allowed. If this flag is not set, only invocation of operations on visible type members is allowed. 
NoFlagsNo reflection is allowed on types that are not visible. 
ReflectionEmitUse of System.Reflection.Emit is allowed. 
TypeInformationReflection is allowed on members of a type that are not visible. 

This enumeration is used by ReflectionPermission. If no ReflectionPermission is granted, reflection is allowed only on visible members.

Caution noteCaution

Because ReflectionPermission can provide access to private class members and metadata, it is recommended that ReflectionPermission not be granted to Internet code.

using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::Runtime::InteropServices;
public ref class ReflectionGenerator
   int reflectionIndex;

      array<ReflectionPermissionFlag>^ temp = {ReflectionPermissionFlag::AllFlags,ReflectionPermissionFlag::MemberAccess,ReflectionPermissionFlag::NoFlags,ReflectionPermissionFlag::ReflectionEmit,ReflectionPermissionFlag::TypeInformation};
      myReflection = temp;

   void ResetIndex()
      reflectionIndex = 0;

   // CreateReflection creates a ReflectionPermission Object*.
   bool CreateReflection( [Out]interior_ptr<ReflectionPermission^> reflectionPerm, [Out]ReflectionPermissionFlag * reflection )
      if ( reflectionIndex >= myReflection->Length )
          *reflectionPerm = gcnew ReflectionPermission( PermissionState::None );
          *reflection = ReflectionPermissionFlag::NoFlags;
         return false;

       *reflection = myReflection[ reflectionIndex++ ];
          *reflectionPerm = gcnew ReflectionPermission(  *reflection );
         return true;
      catch ( Exception^ e ) 
         Console::WriteLine( "Cannot create ReflectionPermission: {0}{1}",  *reflection, e );
          *reflectionPerm = gcnew ReflectionPermission( PermissionState::None );
          *reflection = ReflectionPermissionFlag::NoFlags;
         return true;



// End of ReflectionGenerator.

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions