System.DirectoryServices is not recognised in the namespace 'System'
Solution 1
Is the web-server (IIS or whatever) configured to run the folder as an application (i.e. shows as a cog), and is it using the correct version of ASP.NET? If it is running as 1.1, bits of it might work - but it would fail to find that 2.0 assembly in the 1.1 GAC.
Solution 2
- Right click on References under your solution.
- Select Add Reference. The reference can be found under the Framework Assemblies list. Select System.DirectoryServices and click Add.
Solution 3
Shot in the dark: have you tried adding to the web.config:
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
Solution 4
I think you should install Directory Services Package.
Install-Package System.DirectoryServices -Version 4.0.0
Solution 5
This is a very old thread but just to provide a complete answer for the sake of posterity ;)
This issue occurs if the project is missing a reference to the .Net Component System.DirectoryServices
Adding this reference in the usual manner prefered by you will resolve the issue.
jansokoly
Software developer, outdoor enthusiast, traveller and wine lover, living and working somewhere in the middle of Europe.
Updated on March 06, 2020Comments
-
jansokoly about 4 years
I'm trying to use
System.DirectoryServices
in a web site project and I'm getting this error:The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)
My project has a reference to
System.DirectoryServices
inweb.config
:<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
And I do have
using System.DirectoryServices
in the files where I want to use it.Does anybody have a clue where to look for the problem?