TfsConfigurationServer.GetService<VersionControlServer>() always returns null

11,079

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

Share:
11,079
abatishchev
Author by

abatishchev

This is my GUID. There are many like it but this one is mine. My GUID is my best friend. It is my life. I must master it as I must master my life. Without me, my GUID is useless. Without my GUID I am useless.

Updated on June 16, 2022

Comments

  • abatishchev
    abatishchev almost 2 years

    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?