Page 1 of 1

An item with the same key has already been added.

Posted: Fri Feb 24, 2012 1:24 pm
by surf
Message: An error has occured at http://www.fencesource.com/Vinyl-Adhesi ... 80C22.aspx
Debug Data: An item with the same key has already been added.

I have a ton of these error messages since I upgraded to the last version. The web pages pull up just fine. I don't see an error.

Any help would be apprecaited.
Thanks!!

Re: An item with the same key has already been added.

Posted: Fri Feb 24, 2012 8:11 pm
by AbleMods
I noticed the same thing tonight in my 7.0.7 site. But only infrequently, tons of them like yours. I'm not sure where it's coming from unless it's the page views.

You might try turning off page view tracking just for a little while to see if the messages go away.

Re: An item with the same key has already been added.

Posted: Thu May 02, 2013 2:02 pm
by RichWendrock
We are getting a lot of these errors. Did anyone determine what is causing the problem? Did anyone find a fix?

HERE IS ONE OF THE ERRORS; THE ONLY REFERENCE TO Dictionary`2 IS IN THE FILE Newtoosoft.jSON.xml
wnn280 :: ERROR :: An error has occured at https://www.hillcountrycustomcycles.com/Basket.aspx
Logger: System.Object
Thread: 7
Date: 2013-05-02 11:08:43,968
NDC: (null)

System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Seo.RedirectService.InitializeCache()
at CommerceBuilder.Seo.RedirectService.LocateRedirect(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

HERE IS ANOTHER ONE
wnn280 :: INFO :: Running maintenance routines
Logger: System.Object
Thread: 10
Date: 2013-05-02 11:08:43,765
NDC: (null)

wnn280 :: ERROR :: An error has occured at http://www.hillcountrycustomcycles.com/default.aspx
Logger: System.Object
Thread: 19
Date: 2013-05-02 11:08:43,968
NDC: (null)

System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Re: An item with the same key has already been added.

Posted: Fri May 03, 2013 5:15 am
by ForumsAdmin
By any chance do you have multiple entries for the same custom URL in your system?

Re: An item with the same key has already been added.

Posted: Fri May 03, 2013 5:36 am
by RichWendrock
That is a good question, I was not sure how to verify this without editing every custom page until I displayed the ac_CustomUrls table. There are eight entries and each one has a different URL.

Re: An item with the same key has already been added.

Posted: Tue May 14, 2013 8:42 pm
by efficiondave
I'm seeing this error a lot too. There are no duplicate URLs in my ac_CustomUrls table.

Re: An item with the same key has already been added.

Posted: Wed May 15, 2013 4:25 am
by RichWendrock
I am still getting these errors. I hope that AbleCommerce will respond to this question soon.

System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Seo.RedirectService.InitializeCache()
at CommerceBuilder.Seo.RedirectService.LocateRedirect(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Re: An item with the same key has already been added.

Posted: Wed May 15, 2013 11:41 am
by compunerdy
This has been posted on since 2010..

viewtopic.php?f=42&t=14576&p=72233&hili ... key#p72233

Re: An item with the same key has already been added.

Posted: Fri May 17, 2013 9:16 am
by ForumsAdmin
I am investigatin this. Can you confirm you are using version 7.0.7 Build 14588?

Re: An item with the same key has already been added.

Posted: Fri May 17, 2013 9:30 am
by efficiondave
I'm running 7.0.7 Build 14600 and get an error in a similar vein...

I've seen this error 11 time in the last month:
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.b.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Re: An item with the same key has already been added.

Posted: Fri May 17, 2013 9:41 am
by RichWendrock
Yes, the versions are correct for my system.

Re: An item with the same key has already been added.

Posted: Thu Jun 13, 2013 12:38 pm
by deverill
I see these often in our 7.0.6 store when developing. In my case it's when the page is loaded and I change the code. When I refresh the page I get this error but it is usually on the page in the browser and not just the event log.

On my production server I am also seeing them in the event logs but no reports of customers seeing the error. Here's a partial example:

Exception information:
Exception type: ArgumentException
Exception message: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()

It seems it's starting in the URLRewriter and we have a ton of redirects and custom URLs so it's possible we have a dupe there.

Hope it helps someone.
Jim

Re: An item with the same key has already been added.

Posted: Thu Jun 13, 2013 1:08 pm
by RichWendrock
I have noticed that strange errors occur when maintenance starts up. I have seen this particular error occur around the same time as maintenance starting. I see the error occurred yesterday when a customer was trying to display products in a category. I assume the customer clicked a menu category link. I know that AbleCommerce will not allow you to create a duplicate redirect. You can have many URLs redirecting to the same target URL but you can not have duplicate Request Paths. As for the duplicate custom URLs, I do not see how you can have a duplicate custom URL if there is no duplicate in the ac_CustomUrls table. Display the records in that table to confirm. I am suspicious of the maintenance routines some how causing functions to fail. Functions like the customer displaying a product or category.

Re: An item with the same key has already been added.

Posted: Mon Jun 17, 2013 7:35 am
by RichWendrock
Here is an example of an error that occurred this morning.

wnn280 :: INFO :: Running maintenance routines
Logger: System.Object
Thread: 20
Date: 2013-06-17 06:38:36,633
NDC: (null)

wnn280 :: ERROR :: An error has occured at http://www.hillcountrycustomcycles.com/ ... =0601-0779
Logger: System.Object
Thread: 16
Date: 2013-06-17 06:38:36,711
NDC: (null)

System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

AND THEN THIS ERROR IMMEDIATELY AFTER

wnn280 :: ERROR :: An error has occured at http://www.hillcountrycustomcycles.com/ ... P2186.aspx
Logger: System.Object
Thread: 7
Date: 2013-06-17 06:38:36,711
NDC: (null)

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Re: An item with the same key has already been added.

Posted: Thu Oct 24, 2013 1:44 pm
by crockettdunn
I've experienced similar issues, and I have the same hunch that they're tied to maintenance. In fact, my customURL maintenance times out, so I was hoping to get an answer here to the following:

In what file(s) does the custom URL maintenance occur? I'd like to disable this and run it offline, but I don't want to disable anonymous user maintenance.

Re: An item with the same key has already been added.

Posted: Thu Oct 22, 2015 8:46 am
by crockettdunn
Found the problem. Does anyone know if this is resolved in GOLD? There is a huge sql query failing:

Code: Select all

DELETE FROM CUSTOM_Urls where ID not in (1,2,3,4,5...)

and the comma separated string goes on for over a megabyte. It seems to be listing every non-orphaned customUrl in the store. Wouldn't this be better handled as a nested query rather than enumerating the results of the subquery as a giant list of IDs?

Re: An item with the same key has already been added.

Posted: Fri Oct 23, 2015 5:57 am
by Katie
I could check, but I need some kind of reference to a file first. Where did you copy this code snipet from?

Re: An item with the same key has already been added.

Posted: Fri Oct 23, 2015 8:00 am
by crockettdunn
Hi Katie,

The code snippet came from the app.log. Here is the info preceding it:

Code: Select all

ERROR 2015-10-23 12:02:09,045 28924657ms Object                 RunMaintenance     - Error maintaining custom urls
System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at CommerceBuilder.Data.Database.a(DbCommand A_0)
   at CommerceBuilder.Data.Database.ExecuteNonQuery(DbCommand command)
   at CommerceBuilder.Utility.MaintenanceWorker.a(List`1 A_0, CatalogNodeType A_1)
   at CommerceBuilder.Utility.MaintenanceWorker.i()
   at CommerceBuilder.Utility.MaintenanceWorker.RunMaintenance()
ClientConnectionId:a047ed57-cfc2-4032-b518-f8d222e49370
Error Number:-2,State:0,Class:11
INFO  2015-10-23 12:02:09,060 28924673ms Object                 RunMaintenance     - Maintenance routines complete
INFO  2015-10-23 13:00:05,701 32401313ms Object                 RunMaintenance     - Running maintenance routines
INFO  2015-10-23 13:00:05,717 32401329ms Object                 f                  - User maintenance cleared 1 expired anonymous users, last active before 9/22/2015 5:00:05 PM
INFO  2015-10-23 13:00:07,121 32402733ms Object                 f                  - User maintenance cleared 282 expired affiliate anonymous users, last active before 9/22/2015 5:00:05 PM
INFO  2015-10-23 13:00:07,121 32402733ms Object                 d                  - Payment maintenance cleared 2 expired payments, completed before 8/24/2015 5:00:07 PM
WARN  2015-10-23 13:02:09,024 32524636ms Object                 a                  -  DELETE FROM ac_CustomUrls WHERE...
giant list of customURL IDs here, then:

Code: Select all

System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at CommerceBuilder.Data.Database.a(DbCommand A_0)
ClientConnectionId:6b9d2882-4e80-4bdf-acfd-d2a51bc92b65
Error Number:-2,State:0,Class:11
Not exactly a filename, but I hope that g ives you enough context.

Re: An item with the same key has already been added.

Posted: Mon Oct 26, 2015 5:47 am
by Katie
I did a bit of searching around, and it seems this issue only exists in AC7. Gold has been out for over 3 years now and no one has reported the issue.

It's not easy to do much troubleshooting because I would need to be able to replicate the issue in a stock installation. The error alone doesn't give me all the information needed to generate a bug report that can be used to test.

Re: An item with the same key has already been added.

Posted: Mon Oct 26, 2015 10:06 am
by crockettdunn
If it's fixed in Gold, that's all I need to know. Thanks, Katie!