简体   繁体   English

TfsConfigurationServer.GetService <VersionControlServer> ()始终返回null

[英]TfsConfigurationServer.GetService<VersionControlServer>() always returns null

I'm trying to connect to TFS 2010 using TFS SDK, but can't get VersionControlServer service. 我正在尝试使用TFS SDK连接到TFS 2010,但无法获得VersionControlServer服务。

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: 两者总是返回null:

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

What should I do? 我该怎么办?

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 另请参阅: 连接到项目集合

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM