I frequently build custom tooling against the TFS API. Sometimes Windows Applications but most of the time I build Web Applications.
When building Web Applications it is no secret that your application runs under the credentials of the application pool.
When accessing work items via TFS API from your web application you can get the error:
|Access to the path C:\ProgramData\Microsoft\Team Foundation\Web Access\Cache_v10.0.30319\705997425′ denied|
I have seen this error as well in the SharePoint WebParts that Access TFS.
Cause of this error
You get this error because the user under which the application runs, has no rights on the folder mentioned. Duh ! But why?
Every time your application makes connection to TFS a cache is built up to speed up things in a later stage. This cache consists of a lot of files that are generated.
Visual Studio uses this as well, Visual Studio builds up a cache at:
A little off-topic but if you have any problems with red crosses in Team Explorer or Team Explorer acting weird, delete all files in this folder!
When you don’t want to think about anything, you just give the application pool user of your custom application or the service account of your SharePoint application [Modify] rights to the folder mentioned (c:\programdata….). Make sure you do this on all front-ends if you have a load balanced network.
Sometimes this is fine, sometimes this is not allowed by the sys admins. Don’t fear….there is another way !
You can set the cache path yourself!
In your web.config of your application you can add a appSettings key called [WorkItemTrackingCacheRoot] that has a value of a path that you can decide (c:\temp\cache?). In this way you can have all custom files (your website/service, logging and cache) together and set up rights for all required users.
This key is also used in the WebAccessClient. In this case the value points to (did you already guess?)
C:\ProgramData\Microsoft\Team Foundation\Web Access\Cache_v10.0.30319
Hope this helps !