【发布时间】:2018-08-01 17:32:34
【问题描述】:
我正在尝试为某个项目引用 System.DirectoryServices.AccountManagement,但不断收到此错误。我已经在 VS 2017 中转到 Project > Add Reference 并包含 System.DirectoryServices.AccountManagement.dll。之后,我进入解决方案资源管理器中的参考属性并将“复制本地”属性设置为 true。这是来自 csc 的完整错误消息:
Microsoft (R) Visual C# Compiler version 2.8.3.63029 (e9a3a6c0)
Copyright (C) Microsoft Corporation. All rights reserved.
Program.cs(7,32): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?)
这里有更多信息:
using System;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
...
PrincipalContext context = new PrincipalContext(ContextType.Domain, "mycompany.local");
GroupPrincipal findAllGroups = new GroupPrincipal(context, "*");
PrincipalSearcher ps = new PrincipalSearcher(findAllGroups);
【问题讨论】:
-
投票关闭此作为没有复制,因为 OP 在重建项目解决问题的答案之一下声明。