Reputation: 7628
I created a class GroupPrincipalExtension : GroupPrincipal
as you can see it inherits from System.DirectoryServices.AccountManagement.GroupPrincipal
Now when I try to create a constructor in my extension class,
public new GroupPrincipalExtension()
{
//do something
}
I get this error,
The modifier 'new' is not valid for this item
Based on what I read, we can add own constructors to derived class with or without 'new' keyword
Edit
If i remove new keyword:
'System.DirectoryServices.AccountManagement.GroupPrincipal' does not contain a constructor that takes 0 arguments
Upvotes: 2
Views: 1368
Reputation: 149598
GroupPrincipal
doesn't have a default constructor. It's slimiest constructor is one which takes a PrincipalContext
, which is exactly what you need to take as an argument in your constructor:
public GroupPrincipalExtension(PrincipalContext context) : base(context)
{
//do something
}
Upvotes: 3
Reputation: 2797
Remove new
from the constructor and it should work. You only declare the new
keyword when you're creating an instance.
Also since it inherits from another class you might want to declare it like this:
public GroupPrincipalExtension()
: base() // Parameters ??
{
//do something
}
Upvotes: 3