Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TfsConfigurationServer.GetService<VersionControlServer>() always returns null

Tags:

c#

.net

tfs

tfs-sdk

I'm trying to connect to TFS 2010 using TFS SDK, but can't get 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 returns null:

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

What should I do?

like image 647
abatishchev Avatar asked Feb 23 '11 23:02

abatishchev


1 Answers

You don't want the configuration server, you want the project collection. The version control service is scoped to a team project collection. For example:

var projectCollection =
    TfsTeamProjectCollectionFactory.GetTeamProjectCollection(registeredProjectCollection);

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

See also: Connect to a Project Collection

like image 127
Jim Lamb Avatar answered Sep 19 '22 15:09

Jim Lamb