Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using Visual Studio 2010. When I want to use PrincipalContext Class, the Visual Studio couldn't find the Reference:

enter image description here

I have opened the project with .NET Framework 4 selected and my project was targeting .NET Framework 3.5 in Project Properties.

.NET Framework 3.5+ should have System.DirectoryServices but why this happens?

PS: I am using Application page.

share|improve this question
    
Have you added a reference to System.DirectoryServies.AccountManagement in your project? Are you using that namespace in your code file? –  TZHX Dec 23 '12 at 7:45
    
There is no "System.DirectoryServies" in Reference List to Add! I have no idea what's happening... –  Natasha Dec 23 '12 at 7:48
add comment

1 Answer 1

up vote 4 down vote accepted

I think System.DirectoryServices requires an manual reference to System.DirectoryServices.dll which can be done just by right clicking your project in solution explorer -> Add Reference -> in .NET Tab,

select "System.DirectoryServies.AccountManagement".

Now, you should be able to import System.DirectoryServies.AccountManagement namespace.

Adding Reference to System.DirectoryServies.AccountManagement

If you still can't see it like its shown in above picture then you should try adding reference like this,

<add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

It doesn't matter if you are using application page or not, I would recommend you to go through this article for a better understanding of this new class for Directory services.

Hope it helps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.