命名空间中不存在类型或命名空间名称“DirectoryServices"? [英] The type or namespace name 'DirectoryServices' does not exist in the namespace?

查看:45
本文介绍了命名空间中不存在类型或命名空间名称“DirectoryServices"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CS0234:类型或命名空间名称DirectoryServices"不存在在命名空间System"中(您是否缺少程序集引用?)

CS0234: The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)

此页面运行良好,显示来自直接服务的记录,没有错误.但现在它给出了上述错误.

This page was working fine,show records from directly services with no error. but now it gives the above error.

 <asp:GridView ID="gvUsers" runat="server" AutoGenerateColumns="false" DataSourceID="odsUsers"
                                    AllowPaging="true" AllowSorting="true" Width="100%">
<Columns>
 <asp:TemplateField HeaderText="User Name">
 <ItemTemplate>

<%#((System.DirectoryServices.DirectoryEntry)Container.DataItem).Properties["userPrincipalName"].Value%>

   </ItemTemplate>
   </asp:TemplateField>
/Columns>
</asp:GridView>

项目构建成功,但是当我打开页面时出现错误

Project builds successfully but when I open the page then it gives error

推荐答案

添加目录服务引用后,右键单击 reference 并转到 properties.将 "CopyLocal" 设置为 true.

After you add your directory services reference, right click on the reference and go to properties. Set "CopyLocal" to true.

这篇关于命名空间中不存在类型或命名空间名称“DirectoryServices"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆