How can I implement a attribute like "PrincipalPermission"
i attribute "principalpermission", because when call method mymethod, check permission first. found when check permission failed, throws exception.
my question how can implement attribute this: when check permission failed, not step method "mymethod", instead of throw exception?
[principalpermission(securityaction.demand, role = "user")]
private void mymethod()
{
string ss = "abc";
}
if you're talking principalpermission can following:
if (thread.currentprincipal.isinrole("user"))
{
mymethod();
}
but following, , more generic solution use try/catch block:
try
{
mymethod();
}
catch (securityexception sex)
{
}
to answer question: afaik it's impossible without exceptions, because that's way failures meet required permissions signalled back...
.NET Framework > Common Language Runtime Internals and Architecture
Comments
Post a Comment