I tried two ways to connect to workitemstore for the TFS server in which we work. Attempt A was to connect to the configuration server and use the GetService<WorkItemStore>()
method. This always returns null.
Attempt B was to connect to TfsTeamProjectCollection and use the GetService<WorkItemStore>()
method or pass the project collection to the WorkItemStore constructor. In attempt B, I get an exception: "Error HRESULT E_FAIL was returned from a call to the COM component." The only information I can find on this seems to indicate some permissions issues, but I confirmed that I am authenticated as read-only user to the entire collection of projects, and I connect and intervene accordingly through the VS 2011 preview.
This is how I connect ...
public TfsConfigurationServer GetConfigurationServer() { Uri tfsUri = new Uri(configs.TfsUri); TfsConfigurationServer server = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri, credProvider); server.Authenticate(); if (server.HasAuthenticated == false) throw new InvalidOperationException("You can't authenticate against the tfs instance."); return server; } public TfsTeamProjectCollection GetProjectCollectionInstance(string projectCollectionName) { Uri tfsUri = new Uri(configs.TfsUri + "/" + projectCollectionName); TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri, credProvider); collection.Authenticate(); if (collection.HasAuthenticated == false) throw new InvalidOperationException("You can't authenticate against the tfs instance."); return collection; }
and this is how I try to get WorkItemStore (stupid code to illustrate the problem) ...
public WorkItemProvider() { if (workItems == null) workItems = ServerProvider.ServerInstance.GetService<WorkItemStore>(); if (workItems == null) workItems = ServerProvider.ProjectCollectionInstance.GetService<WorkItemStore>(); if (workItems == null) workItems = new WorkItemStore(ServerProvider.ProjectCollectionInstance); if (workItems == null) throw new NullReferenceException("Couldn't load work item store."); }
I am not on the same domain as the server, but I authenticate as a domain user using ICredentialsProvider, and I have verified that I am authenticated as this user. Any pointers would be helpful.
source share