Problem Creating Work Item Store From Web Service (Work Item Tracking Metadata Cache)
Problem Creating Work Item Store From Web Service (Work Item Tracking Metadata Cache)
I create a Web Service for a customer and during the development I had a little problem getting WorkItemStore object.
Error 1:
Cannot complete the operation. An unexpected error occurred.
Stake: at Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.HandleComException(Int32 hr)
at Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.DatastoreClass.ConnectEx(String connectionString, Int32 hCredentials, String defaultCachePath, String instanceId, String userSamName, String userFriendlyName, String userSid)
at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.InitializeInternal()
at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.Microsoft.TeamFoundation.Client.ITeamFoundationServerObject.Initialize(TeamFoundationServer teamFoundationServer)
at Microsoft.TeamFoundation.Client.TeamFoundationServer.CreateITFSObjectInstance(Assembly assembly, String fullName)
at Microsoft.TeamFoundation.Client.TeamFoundationServer.GetService(Type serviceType)
at WorkItemChangeService.WorkItemChangeEvent.Notify(String eventXml) in D:\Shai Raiten\Visual Studio 2008\Projects\WorkItemChangeService\WorkItemChangeService\WorkItemChangeEvent.asmx.cs:line 42.
Error 2:
Detailed Message: TF200034: A subscriber to a Team Foundation event (subscription ID=312) raised the following exception:
Exception Message: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Microsoft.TeamFoundation.WorkItemTracking.Client.UnexpectedErrorException: Cannot complete the operation. An unexpected error occurred. ---> Microsoft.TeamFoundation.WorkItemTracking.Client.ClientException: Access is denied.
(Windows)
Could not create metadata cache directory 'C:\Documents and Settings\Default User\Local Settings\Application Data\Microsoft\Team Foundation\2.0\Cache\c9a5515a-0e91-4550-9c54-74c84a4cfd97'. (Work Item Tracking Metadata Cache)
The system cannot find the path specified.
(Windows)
Could not create metadata cache directory 'C:\Documents and Settings\Default User\Local Settings\Application Data\Microsoft\Team Foundation\2.0\Cache\c9a5515a-0e91-4550-9c54-74c84a4cfd97\0'. (Work Item Tracking Metadata Cache)
Could not open file ''. (Work Item Tracking Metadata Cache)
Access is denied.
(Windows)
Could not create metadata cache directory 'C:\Documents and Settings\Default User\Local Settings\Application Data\Microsoft\Team Foundation\2.0\Cache\c9a5515a-0e91-4550-9c54-74c84a4cfd97'. (Work Item Tracking Metadata Cache)
The system cannot find the path specified.
(Windows)
Could not create metadata cache directory 'C:\Documents and Settings\Default User\Local Settings\Application Data\Microsoft\Team Foundation\2.0\Cache\c9a5515a-0e91-4550-9c54-74c84a4cfd97\0'. (Work Item Tracking Metadata Cache)
Could not open file ''. (Work Item Tracking Metadata Cache)
Could not initialize metadata cache for product 'c9a5515a-0e91-4550-9c54-74c84a4cfd97'. (Work Item Tracking Metadata Cache)
Unspecified error
(Windows)
--- End of inner exception stack trace ---
at WorkItemChangeService.WorkItemChangeEvent.Notify(String eventXml) in D:\Shai Raiten\Visual Studio 2008\Projects\WorkItemChangeService\WorkItemChangeService\WorkItemChangeEvent.asmx.cs:line 55
--- End of inner exception stack trace --- (type SoapException)
Exception Stack Trace: at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Microsoft.TeamFoundation.Server.NotificationClient.Notify(String eventXml, String tfsIdentityXml, SubscriptionInfo SubscriptionInfo)
The problem is in the ClientCacheDirectoryForInstance property on the TeamFoundationServer class.
The problem was fixed by giving write permissions for the application pool to the Cache folder.
The Solution
Enable Integrated Windows Authentication and Turn Off Anonymous Access
Open inetmgr, right click “Web Application” and choose properties.
Select “Directory Security” and enter “Authentication Methods”
Clear all checkbox except “Integrated Windows Authentication”.

Create an Application Pool for a Web Application
Create a default application pool and enter the Identity of the user name for the domain account under which you want your Web page to run in the User name field, using the domain\user name format.

Change Web Application to Work With the New ApplicationPool
This will fix the problem.