2
votes

When I try to get some items from Sitecore in a TDS project I get this error:

"An item with the same key has already been added. Error communicating with TDS service. Please see the Application Exception Log on the Sitecore Server for more details."

The strange thing is that the item is eventually added to the TDS project. Also I am using custom data provider.

What I have tried until now:

  1. Create new TDS proj and the first time I get the items there is no problem, but if I delete them and later decide to get them from SC get the same error.
  2. Verified that items have only one version and language
  3. Turned off "Code Generation"
  4. There might be a problem in versions and languages in the DataProvider but I checked it and it looks ok.
6

6 Answers

7
votes

The problem you are seeing can occur when you have removed items from the TDS project and then you sync again. TDS keeps a cache of keys added to the project and doesn't seem to be able to remove those cached keys if the items are removed from the Visual Studio project by selecting them and deleting them in the Solution Explorer.

The only way I've found to get around that issue is to close Visual Studio and reload.

0
votes

TDS doesn't support having sibling items with the same name which is why you're seeing this error. Try renaming the duplicate named item and see if this allows the synch to work.

0
votes

I also ran into this a couple weeks ago- after a little investigation I realized the error An item with the same key has already been added was actually a .net error being thrown by TDS. I don't think (at least in my case) it has anything to do with a TDS item conflict. Although I never found out what the actual problem was- bouncing the app pool seemed to help.

0
votes

The TDS cache is stored under the obj folder in project directory. Try to delete this folder and restart the code generation for TDS.

0
votes

Yes, restarting visual studio helped clear the cache. Also make sure you restart VS in admin mode.

0
votes

Thanks everyone for your help! Somehow I managed to fix the project. Based on the things i have tried if someone encounter similar problem, you can try these things:

  1. "bad merge" - it is possible when you merge to duplicate fields which will result in the same problem.
  2. Make sure you don't have items with the same name on a same level (items with same id will reproduce the same error for sure)
  3. If you are using custom data provider make sure it does not create useless item versions or adding useless languages. Check this thread: Sitecore Custom Data Provider doubles language versions?
  4. As Richard said TDS have cache so restarting the VS may help.

Hope this will help!