bugnet icon indicating copy to clipboard operation
bugnet copied to clipboard

Error: Item has already been added. Key in dictionary: [USER]

Open efficiondave opened this issue 10 years ago • 1 comments

Ran into a strange issue today. We couldn't edit projects. When we tried we'd get the below error. I looked in the database and there 4 instances of one user all having the same username. All instances of the user were created at the exact same time. We are using the Active Directory integration so they were created automatically. Not sure if this occurred due to an odd one time glitch or the user did something weird. Perhaps the best solution is to add a unique constraint to the Username field in the users table?

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Item has already been added. Key in dictionary: '[USER NAME REDACTED]' Key being added: '[USER NAME REDACTED]' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Web.Security.MembershipUserCollection.Add(MembershipUser user) at System.Web.Providers.DefaultMembershipProvider.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords) at BugNET.Providers.MembershipProviders.ExtendedSqlMembershipProvider.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords) in e:\Visual Studio 2010\WebSites\BugNet\src\Library\Providers\MembershipProviders\ExtendedSqlMembershipProvider.cs:line 118 at BugNET.Administration.Projects.UserControls.ProjectDescription.Initialize() at BugNET.Administration.Projects.EditProject.LoadTab(Int32 selectedTab) at BugNET.Administration.Projects.EditProject.Page_Load(Object sender, EventArgs e) at BugNET.UserInterfaceLayer.BasePage.OnLoad(EventArgs e) at System.Web.UI.Control.<LoadRecursiveAsync>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Util.WithinCancellableCallbackTaskAwaitable.WithinCancellableCallbackTaskAwaiter.GetResult() at System.Web.UI.Page.<ProcessRequestMainAsync>d__14.MoveNext() at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.<ProcessRequestMainAsync>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

efficiondave avatar May 19 '15 20:05 efficiondave

This reoccurred. Issue #193 seems to be the best exploration of the problem. I can confirm I'm using Active Directory and the Unique constraint was not checked for the Index. I've now checked the Unique constraint after removing the duplicates. Hoping that resolves it.

efficiondave avatar Oct 13 '16 17:10 efficiondave