TfsConfigurationServer.GetService <VersionControlServer> () always returns null

I am trying to connect to TFS 2010 using the TFS SDK but cannot get the VersionControlServer service.

var servers = RegisteredTfsConnections.GetConfigurationServers(); // ok 

then

 var tfs = new TfsConfigurationServer(servers.First().Uri, CredentialCache.DefaultNetworkCredentials); // or var tfs = new TfsConfigurationServer(servers.First()); 

both always return null:

 var vc = (VersionControlServer)tfs.GetService<VersionControlServer>(); // null! 

What should I do?

+8
c # tfs tfs2010 tfs-sdk
source share
1 answer

You do not need a configuration server, you need a project collection. The version control service is tied to the collective team of the project. For example:

 var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(registeredProjectCollection); var versionControl = projectCollection.GetService<VersionControlServer>(); 

See also: Connect to a collection of projects

+19
source share

All Articles