Membership.GetAllUsers() gives error "Item has already been added"

1.4k Views Asked by At

I'am using the Membership provider and now facing the following error:

System.ArgumentException: Item has already been added. Key in dictionary: '0859929000' Key being added: '0859929000'

The Key is the UserName from the aspnet_Users table, which has no duplicates.

This code generates the error:

private void BindUsersToUserList()
{
    // Get all of the user accounts
    MembershipUserCollection users = Membership.GetAllUsers();
    UserList.DataSource = users;
    UserList.DataBind();
}

All users are imported manually by me using the stored procedures aspnet_Users_CreateUser and aspnet_Membership_CreateUser.

Now, the question is, where is the problem? Is there anywhere else in the database duplicates might occur (tables, corrupt indexes etc.) and cause this problem?

1

There are 1 best solutions below

0
On

Problem solved.

There were duplicates in the LoweredUserName column. I missed that somehow.