TfsConfigurationServer.GetService< VersionControlServer>()始终返回null [英] TfsConfigurationServer.GetService<VersionControlServer>() always returns null

查看:339
本文介绍了TfsConfigurationServer.GetService< VersionControlServer>()始终返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到TFS 2010使用TFS SDK,但不能得到VersionControlServer服务。

I'm trying to connect to TFS 2010 using TFS SDK, but can't get VersionControlServer service.

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

然后

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

这两个始终返回null:

both always returns 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>();

另请参见:<一href="http://archive.msdn.microsoft.com/TfsSdk/Wiki/View.aspx?title=Connect%20to%20Project%20Collection&referringTitle=Home">Connect一个项目集合

这篇关于TfsConfigurationServer.GetService&LT; VersionControlServer&GT;()始终返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆