TfsTeamProjectCollectionFactory.GetTeamProjectCollection failing despite available TFS server
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();
精彩评论