2

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.
Robotnik
  • 3,643
  • 3
  • 31
  • 49
IIvanov
  • 137
  • 2
  • 11

6 Answers6

7

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.

Richard Seal
  • 4,248
  • 14
  • 29
  • Hi Richard, for testing purposes i deleted all the items from the tds project and than closed VS. After that when i try to get them from sitecore i got error: "1 error(s) encountered attepmtiong to perform the add operation on 1 item(s) The item.... already existes. See output ..." After a couple of ok click on the error the items are added to the project but not structured in folders. – IIvanov Apr 30 '14 at 15:34
  • 1
    Check the filesystem and make sure the items have actually been deleted too. Just deleting from VS doesn't always do the trick. If your TDS project is source controlled then you may have to check-in after the initial delete operation too. – jammykam May 01 '14 at 17:47
0

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.

Matthew Dresser
  • 11,273
  • 11
  • 76
  • 120
  • Hi mdresser, I can confirm that I don't have duplicate item names on a same level, which is the only requirement from tds. Also tested something which does not reproduce the error: I created a fresh tds project and successfully got the items from sitecore and no trouble in syncing . But in my real tds project if I try to sync it throws an error: “An exception occurred when syncing with sitecore. Please see the output window for more details”. – IIvanov Apr 30 '14 at 14:00
0

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.

McCheeseIt
  • 355
  • 1
  • 8
0

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!

arjunan
  • 105
  • 4
IIvanov
  • 137
  • 2
  • 11
0

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

Jack Spektor
  • 1,097
  • 1
  • 11
  • 30
0

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