views:

1068

answers:

3

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 in web.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?

A: 

Is this a web site project, or a web application project. With the latter, references are handled via the .csproj - i.e. via the "References" node in Solution Explorer.

Marc Gravell
it's a web site, so this isn't the issue thanks anyway
cruster
A: 

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>
Mitch Wheat
got exactly the same piece of code
cruster
what about any assemblies that System.DirectoryServices is dependent upon?
Mitch Wheat
+3  A: 

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.

Marc Gravell
this has solved my problem<br>thanks a lot
cruster