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
After you add your directory services reference, right click on the reference
and go to properties
. Set "CopyLocal"
to true.