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.