开发者

TfsTeamProjectCollectionFactory.GetTeamProjectCollection failing despite available TFS server

开发者 https://www.devze.com 2023-03-24 16:46 出处:网络
So, I have a TFS server at http://mytfsserver:8080. I\'m connected to it fine from visual studio doing all the usual TFSy things without any issue at all.

So, I have a TFS server at http://mytfsserver:8080. I'm connected to it fine from visual studio doing all the usual TFSy things without any issue at all.

I'm trying to connect from code though - I do the following:

tfs 开发者_如何学编程=  TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://mytfsserver:8080"));
tfs.EnsureAuthenticated();

But I get a TeamFoundationServiceUnavailableException.

I'm not connecting to my server in any funny ways, so what is different about what I'm doing to what VS does when it connects?


You just need to add the collection name at the end of the Uri

var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
    new Uri("http://TFS:8080/TFS/DefaultCollection"));


Try adding /tfs to your server URI.

var tfsServerUri = new Uri("http://mytfsserver:8080/tfs");
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsServerUri);
tfs.EnsureAuthenticated();
0

精彩评论

暂无评论...
验证码 换一张
取 消