Re: bug? -- PrincipalPermissionAttribute & GetCustomAttributes

From: Shawn Farkas [MS] (shawnfa_at_online.microsoft.com)
Date: 06/21/03


Date: Fri, 20 Jun 2003 15:54:46 -0700


Hi Alex,

    Unfortunately, although they look like custom attributes when you apply
them, declarative security demands are not stored as custom attributes in an
assembly. Therefore you won't be able to see them when you reflect over the
custom security. In current releases of the framework, there is no way to
use reflection to access declaritive security, although we are considering
adding this feature to a future version.

-Shawn

-- 
--------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights
"lx" <alex@merchise.com> wrote in message 
news:#jRf$s2NDHA.2832@TK2MSFTNGP10.phx.gbl...
> Hi,
> I'm trying to get a
> "System.Security.Permissions.PrincipalPermissionAttribute" from some
> "MemberInfo", e.g.
>
> public void attrTest()
>   {
>     MemberInfo member = this.GetType().GetMember("testMember")[0];
>     object[] attrs = member.GetCustomAttributes(false);
>     foreach(object attr in attrs)
>       Console.WriteLine(attr);
>   }
>
> [System.Obsolete("Test")]
> [System.ComponentModel.Category("Test")]
> [System.Security.Permissions.PrincipalPermission(SecurityAction.Demand)]
> public void testMember()
>   {
>   }
>
>
> The ouput is:
>
> System.ComponentModel.CategoryAttribute
> System.ObsoleteAttribute
>
> What's wrong?. Anyone knows why "GetCustomAttributes" doesn't retrieve
> PrincipalPermission attributes?
>
> thanks in advance
>
> alex
>
>