TFSSync plugin fails to start with ResolutionFailedException because TFS client cache got corrupt (COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.)

The TFSSync plugin may fail because the TFS client cache has been corrupted, and the plugin cannot be restarted until this has been resolved.

This error currently occurs very rarely. Please contact us if you experience this error, even if you can apply the workaround below.

Symptoms
When the TFS client cache is corrupted, the plugin shows the status "Failed" and the following error is logged by the server:

Message: The plugin 'TechTalk.TFSSync' (repo: some id) failed to start: Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "TechTalk.SpecLog.Server.Plugins.TFSSync.IWorkItemSynchronizer", name = "(none)". 
Exception occurred while: Calling constructor TechTalk.SpecLog.Server.Plugins.TFSSync.VsScrumV2Overrides(TechTalk.SpecLog.Server.Plugins.TFSSync.ITfsProjectService tfsProjectService, TechTalk.SpecLog.Logging.ILogger logger). 
Exception is: COMException: Error HRESULT E_FAIL has been returned from a call to a COM component. 
----------------------------------------------- 
At the time of the exception, the container was:

Resolving TechTalk.SpecLog.Server.Plugins.TFSSync.WorkItemPollingSynchronizer,(none) (mapped from TechTalk.SpecLog.Server.Plugins.TFSSync.IWorkItemSynchronizer, (none)) 
Resolving parameter "workItemService" of constructor TechTalk.SpecLog.Server.Plugins.TFSSync.WorkItemPollingSynchronizer(TechTalk.SpecLog.DataAccess.Boundaries.IBoundaryFactory boundaryFactory, TechTalk.SpecLog.DataAccess.Boundaries.IBoundary boundary, TechTalk.SpecLog.Logging.ILogger logger, TechTalk.SpecLog.Entities.ITimeService timeService, TechTalk.SpecLog.Server.Plugins.TFSSync.IWorkItemPollerConfiguration config, TechTalk.SpecLog.Server.Plugins.TFSSync.ITfsWorkItemService workItemService, TechTalk.SpecLog.CommandBuilding.ICommandBuilderFactory commandBuilderFactory, TechTalk.SpecLog.DataAccess.Repositories.IRequirementRepository requirementRepository) 
Resolving TechTalk.SpecLog.Server.Plugins.TFSSync.VsScrumV2Overrides,(none) (mapped from TechTalk.SpecLog.Server.Plugins.TFSSync.ITfsWorkItemService, (none)) 
Calling constructor TechTalk.SpecLog.Server.Plugins.TFSSync.VsScrumV2Overrides(TechTalk.SpecLog.Server.Plugins.TFSSync.ITfsProjectService tfsProjectService, TechTalk.SpecLog.Logging.ILogger logger)

Resolution
We are currently investigating this issue together with with Microsoft support to determine how we can prevent this error from occurring.

Until then, you can delete the TFS client cache as a workaround, which resolves the issue with the corrupted cache and allows you to restart the plugin:

1) Navigate to the service user's directory (the user the SpecLog service is running.under; this is NOT the user account configured for authenticating the TFSSync plugin with TFS).
This is typically "c:\users\{username}", or if the service is running under LocalSystem, then "C:\Windows\System32\config\systemprofile".

2) Delete the contents of the cache directory, located in the user directory at:
AppData\Local\Microsoft\Team Foundation\4.0\Cache

3) Restart the plugin.

Feedback and Knowledge Base