System.DirectoryServices is not recognised in the namespace 'System'

后端 未结 9 1292
一整个雨季
一整个雨季 2021-02-05 02:23

I\'m trying to use System.DirectoryServices in a web site project and I\'m getting this error:

The type or namespace name \'DirectoryServices

相关标签:
9条回答
  • 2021-02-05 02:59

    On Solution Explorer right-click your project, then from the resulting menu, click on Add Reference, then under the .NET tab navigate to DirectoryServices.AccountManagement

    0 讨论(0)
  • 2021-02-05 03:01

    These problems occur when you are working with older .net version and trying to build with the latest IDE

    It depends on which version of IDE you are using and also the current code version.

    Check the web config,

    In my case, I was using the Latest version i.e 4.7 and directoryService assembly are still referring to C#4.0.

    Add below if you are using Latest version of id i.e 4.7

      <system.web>
      <location>
    
    <compilation debug="false" numRecompilesBeforeAppRestart="100" targetFramework="4.7">
            <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>
    </system.web>
      </location>
    
    0 讨论(0)
  • 2021-02-05 03:05

    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.

    0 讨论(0)
提交回复
热议问题