2013-01-01 24 views
9

Theo MSDN phương pháp GetTeamProjectCollection(RegisteredProjectCollection projectCollection, ICredentialsProvider fallbackCredentialsProvider của lớp TfsTeamProjectCollectionFactory hiện đang bị phản đối:Thay thế cho TfsTeamProjectCollectionFactory.GetTeamProjectCollection tham ICredentialsProvider

  • "Lưu ý: API này bây giờ là lỗi thời."

  • [ObsoleteAttribute("This method has been deprecated and will be removed in a future release. See GetTeamProjectCollection(RegisteredProjectCollection) instead.", false)]

Lời khuyên là sử dụng quá tải mà chỉ mất các RegisteredProjectCollection, nhưng những gì chúng ta nên sử dụng từ giờ trở đi, nếu chúng ta muốn có một cơ chế dự phòng cho thông tin?

Cảm ơn

Trả lời

12

Bạn cần phải sử dụng mới TfsTeamProjectCollection constructor cùng với TfsClientCredentials constructor này cho phép nhắc nhở tương tác để xác thực.

// 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); 
+0

Dường như chỉ hoạt động với VS2012 chỉ –

+0

Chỉ hoạt động tốt với VS2010, bạn cần tham khảo các hội đồng phù hợp. – gabrielmaldi

+0

Tôi nghĩ rằng hội đồng cần thiết là "Microsoft.TeamFoundation.Client.dll". Tôi đã sử dụng "11.0.0.0", nhưng những người khác cũng có thể làm việc. – granadaCoder