Debugger is not entering custom attribute class

本秂侑毒 提交于 2020-06-14 06:47:07

问题


This is a C# WPF application for a desktop. I've created a custom attribute class but in debug it never goes in there. Do I need to add something else to this class?

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class Authentication : Attribute, IPrincipal
{
    public Authentication(string id)
    {
        throw new NotImplementedException();
    }

    public IIdentity Identity { get; private set; }

    public bool IsInRole(string role)
    {
        throw new NotImplementedException();
    }

}

And the method is:

    [Authentication(SecurityConstants.DataEntrySupervisor)]
    [Authentication(SecurityConstants.DataVerificationClerk)]
    public void Submit(EventObject eventObject)
    {//////////}

回答1:


An attribute is not called by the runtime in any way. It probably does not even get instanciated until you poke around with reflection.

You can look at SecurityAttribute if you want to do code security with attributes.



来源:https://stackoverflow.com/questions/22714541/debugger-is-not-entering-custom-attribute-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!