Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Getting crazy with Deny()

Getting crazy with Deny()

Scheduled Pinned Locked Moved C#
securityquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    marcossl
    wrote on last edited by
    #1

    I WANT make it clear that i dont want the highlighted code to run but it does, can make someone tell me why? the permissions (intersecting all policy levels) for the assembly are unrestricted access to reflection. I checked it myself. I'm sure there is no mistake in the policy configurations using System; using System.Reflection; using System.Security; using System.Security.Permissions; [assembly:ReflectionPermissionAttribute(SecurityAction.RequestRefuse,Unrestricted=true, Flags = ReflectionPermissionFlag.AllFlags)] namespace reflectsecuritytest { public class mo { public static void met( int i ) { } public static void met( float f ) { } public static void met( string s ) { } public static int met( decimal d ) { return 1; } public static void met( object o ) { } public int i = 9; public static int x = 2; private int pr { get { return 2; } } } [ ReflectionPermissionAttribute( SecurityAction.Deny, Flags = ReflectionPermissionFlag.AllFlags, Unrestricted = true ) ] class Class1 { public static void PermisosReflect() { ReflectionPermission sec = new ReflectionPermission( ReflectionPermissionFlag.AllFlags ); try { sec.Deny(); //************************* //************************* // ********************************* // the next code is supposed not to execute, but it does //************************* //************************* //************************* Type t = typeof( mo ); BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static; foreach( MemberInfo mi in t.GetMembers( bf ) ) { Console.WriteLine( mi ); }; } catch( SecurityException e ){ Console.WriteLine( e ); } } public static void Deny() { Console.WriteLine("before calling"); ReflectionPermission sec = new ReflectionPermission( ReflectionPermissionFlag.AllFlags ); sec.Deny(); PermisosReflect();

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups