<p>I realize you can't get the target entity in the Attribute itself, but what about in an associated Permission object when using a CodeAccessSecurityAttribute?  The Permission object gets called at runtime so it seems there should be a way but I'm at a loss.</p>

<pre><code>public sealed class MySecurityAttribute : CodeAccessSecurityAttribute
{
    public override IPermission CreatePermission()
    {
        MySecurityPermission permission = new MySecurityPermission();

        //set its properties
        permission.Name = this.Name;
        permission.Unrestricted = this.Unrestricted;
        return permission;
    }

}

public class MySecurityPermission : IPermission, IUnrestrictedPermission
{

    public MySecurityPermission(PermissionState state)
    {
           // what method was the attribute decorating that
           // created this MySecurityPermission?
    }

    public void Demand()
    {
           // Or here?
    }
}
</code></pre>

Well, I guess you could use reflection to scan through all the loaded assemblies, looking for any class/member that has
```
this
```
as an attribute.  It'd be quite slow, though, so it's not something you'd want to do often, or in a large project.