【问题标题】:System.DirectoryServices compilation problemsSystem.DirectoryServices 编译问题
【发布时间】:2011-09-06 23:51:48
【问题描述】:

我在这里使用代码:ASP.NET How to get List of Groups in Active Directory

具体来说:

using System.DirectoryServices;

DirectoryEntry objADAM = default(DirectoryEntry); //compiler error!

问题:编译器说它不知道 DirectoryEntry 是什么。

我尝试将其添加到我的 web.config:

      <assemblies>
          <!-- ... -->
          <add assembly="System.DirectoryServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>

但这似乎没有帮助,所以我尝试添加参考:

Someone suggested 设置 Copy Local = True 但这也无济于事。

我注意到我没有看到 System.DirectoryServices 的引用 - 只有 System.DirectoryServices.Accountmanagement

谁能帮我编译这段代码?我不确定接下来要尝试什么。

【问题讨论】:

    标签: active-directory compiler-errors asp.net-3.5 directoryservices


    【解决方案1】:

    在“添加引用”对话框中去掉 .net 3.5 过滤器,然后在您的项目中添加一个引用:

    System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

    您可以通过更改项目设置来关闭过滤器:http://msdn.microsoft.com/en-us/library/bb398202.aspx

    【讨论】:

    • 我不知道如何从“添加引用”对话框中删除 .Net 3.5 过滤器。但是,我直接在 web.config 中添加了上述行,它工作正常。谢谢。
    【解决方案2】:

    如果您想使用 System.DirectoryServices 命名空间中的 DirectoryEntry - 您需要添加对 System.DirectoryServices 程序集的引用 - System.DirectoryServices.AccountManagement 程序集!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-26
      • 2020-04-03
      • 2010-10-04
      • 2018-02-15
      • 2011-04-08
      • 2020-07-16
      相关资源
      最近更新 更多