TF30170 errors and the TFS Cache

Weird things happen, like this:

0

An item with the same key has already been added.How?!

Nothing catastrophic actually – it is just a matter of clearing the cache. This happened because this instance of Team Foundation Server was restored as part of a Disaster Recovery exercise, and its ID was not changed.

So, in order to solve this (and other similar TF30170 errors) just look at the logs – if you find that explanation message in one of the exceptions, or similar (like “cannot add LinkTypes relationship”) then I would suggest to clear the Team Foundation Cache:

<OSDrive>:\Users\<youruser>\AppData\Local\Microsoft\Team Foundation\

There are some folders in there, each containing a Cache folder. Empty those Cache folders, and try again. If there is nothing actually wrong underneath the Team Project would be created without problems.

A couple of remarks: it happens that the Team Project would be actually allocated on your target server even if the creation fails (it won’t be accessible and it is shown as Deleting). In this scenario it is pretty common that Visual Studio launches part of the temporary Team Project deletion but it would fail because it is not pointing at the right server GUID – open the TFS Admin Console and relaunch a manual deletion on the temporary Team Project.

Eventually, this might happen because you are not marking your Transaction Logs backups, so you restored some of the database out of the right order. Please use the TFS Backup Tool, or if you can’t, mark the transactions so you won’t hit that again.