The type or namespace name 'DirectoryServices' does not exist in the namespace? The type or namespace name 'DirectoryServices' does not exist in the namespace? asp.net asp.net

The type or namespace name 'DirectoryServices' does not exist in the namespace?


After you add your directory services reference, right click on the reference and go to properties. Set "CopyLocal" to true.


I'm pretty sure that I'm "publishing" my application from my development box to my IIS box completely incorrectly. However, I found this solution here, and it worked for me.

If you are using web application then in your web.config add the following code.

<compilation debug="true" targetFramework="4.0" >    <assemblies>        <add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>        <add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>    </assemblies></compilation>


1 - Right-Click Mouse Button on "References"
2 - Click "Add Reference ..."
3 - Click "Browse" Button
4 - Find the following files in folder:

"C:\Program Files\Reference\Assemblies\Microsoft\Framework\.NETFramework\v4.6.1"

-System.DirectoryServices.dll
-System.DirectoryServices.AccountManagement.dll

5 - Select them
6 - Press "OK" Button