RegisteredTfsConnections.GetProjectCollection returns null on test server, but not on dev server

纵然是瞬间 提交于 2019-12-06 16:01:03

I use:

var uri = new Uri("http://myserver/");
var server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri);

I had the same issue. The RegisteredTfsConnections.GetProjectCollection() method was not consistently returning collections. This wasn't by user but strangely by computer. My dev box showed all collections and my test box showed none.

In my research I found an MSDN article/solution which may help anyone whom currently wants to get a list of TFS collections on the server.

"Sample Code: Connect to Team Foundation Server" by Allen Clark

It worked for me in Team Foundation Server Object Model v12.

mrfelis

I ran into the same issue today. The reason why I was getting a null return was that some users were using TFS through the web interface and they had not added the server through the Visual Studio plugin for TFS.

The answer from RegisteredTfsConnections.GetProjectCollection I get null exception also worked for this situation.

var tfs = new TfsTeamProjectCollection(new Uri("http://example.com:8080/tfs/DefaultCollection"));
var versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!