try versioning
public new bool Authorize(IPrincipal principal, List<string> rightsRequested)
{
do something
}
Main Topics
Browse All TopicsMy new derived class inherits from an abstract class. In the abstract class, it has this method:
public abstract bool Authorize(IPrincipal principal, string context);
I want to override this method because I want to implement it like this in my derived class:
public override bool Authorize(IPrincipal principal, List<string> rightsRequested)
{
do something
}
However I get the errors:
'Microsoft.Practices.Enter
'Microsoft.Practices.Enter
Where VAuthorizationProvider is my new class that inherits the abstract class AuthorizationProvider.cs
CAn you not override a class in an abstract class? I would think this would be a common task?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I tried that, in fact tried this:
1 public new bool Authorize(IPrincipal principal, List<string> rightsRequested)
2 {
3 bool result = false;
4
5 if (principal == null) throw new System.ArgumentNullExcepti
6 if (rightsRequested.Count < 1) throw new System.ArgumentNullExcepti
7
8 if (rightsRequested.Count == 1)
9 {
10 dicRights[principal.Identi
11 }
12
13 return result;
14 }
15
16 public bool Authorize(IPrincipal principal, string context)
17 {
18 return false;
19 }
but that doesn't work for me, I get errors:
Errors (what am I doing wrong?):
Error 3 'Microsoft.Practices.Enter
Error 2 Warning as Error: 'Microsoft.Practices.Enter
Error 1 Warning as Error: The member 'Microsoft.Practices.Enter
Ok, I know that I have to satisfy the abstract class by implementing Authorize. But I want to hide it and use my own Authorize signature (meaning arguments) where I'm passing a generic string and implementing it that way. So what am I doing wrong here?
"By default, C# methods are not virtual if a method is declared as virtual, any class inheriting the method can implement its own version. To make a method virtual, the virtual modifier is used in the method declaration of the base class. The derived class can then override the base virtual method by using the override keyword or hide the virtual method in the base class by using the new keyword. If neither the override keyword nor the new keyword is specified, the compiler will issue a warning and the method in the derived class will hide the method in the base class."
IT would appear that the Authorize method in the base class has not been defined as virtual, thus you cannot provide your own version.
Business Accounts
Answer for Membership
by: TheLearnedOnePosted on 2007-10-12 at 07:51:29ID: 20065887
You need to match the method signature that you are trying to override, or the compiler cannot find a match, since you can have overloaded methods with different signatures.
Bob