根据MSDN,GetTeamProjectCollection(RegisteredProjectCollection projectCollection, ICredentialsProvider fallbackCredentialsProvider
类的方法TfsTeamProjectCollectionFactory
现已弃用:
“注意:此API现已过时。”
[ObsoleteAttribute("This method has been deprecated and will be removed in a future release. See GetTeamProjectCollection(RegisteredProjectCollection) instead.", false)]
建议是使用仅占用RegisteredProjectCollection
的重载,但是如果我们想要一个凭证的回退机制,我们应该从现在开始使用什么?
由于
答案 0 :(得分:12)
您需要使用新的TfsTeamProjectCollection constructor以及此TfsClientCredentials constructor,它允许交互式提示进行身份验证。
// Use default windows credentials, and if they fail, AllowInteractive=true
var tfsCreds = new TfsClientCredentials(new WindowsCredential(), true);
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
new Uri("http://yourserver:8080/tfs/DefaultCollection"),
tfsCreds);