Assembly reference from ASP.NET App_Code directory

Posted by Gerald Schneider on Stack Overflow See other posts from Stack Overflow or by Gerald Schneider
Published on 2010-03-23T10:19:21Z Indexed on 2010/03/23 10:23 UTC
Read the original article Hit count: 384

I have trouble getting a custom ObjectDataSource for an asp:ListView control to work. I have the class for the DataSource in the App_Code directory of the web application (as required by the asp:ListView control).

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Web;
using System.DirectoryServices;

    [DataObject]
    public class UsersDAL
    {
        [DataObjectMethod(DataObjectMethodType.Select)]
        public List<User> LoadAll(int startIndex, int maxRows, string sortedBy)
        {
            List<User> users = new List<User>();

            DirectoryEntry entry;

            return users;
        }
    }

As soon as I add using System.DirectoryServices; the page crashes with this message:
Compiler Error Message: CS0234: The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)
Without the usage of System.DirectoryServices the page loads without problems.

The reference is there, it is working in classes outside the App_Code directory.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about active-directory