0
我想在Visual Studio Team Services(以前的Visual Studio Online)中創建一個任務/工作項目。我的代碼失敗,因爲「tfsStore」返回空值導致異常被拋出。無法初始化TFS商店
NetworkCredential myNetCredentials = new NetworkCredential("*****", "******");
ICredentials myCredentials = (ICredentials)myNetCredentials;
Uri tfsUri = new Uri("https://*****.visualstudio.com/DefaultCollection/");
var tfsServer = new TfsTeamProjectCollection(tfsUri, myCredentials);
tfsServer.EnsureAuthenticated();
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(tfsUri);
WorkItemStore tfsStore = tfsServer.GetService<WorkItemStore>();
if (tfsStore == null)
{
throw new Exception("Cannot initialize TFS Store");
}
Project teamProject = tfsStore.Projects["******"];
我將不勝感激關於如何解決錯誤的任何有用的提示。 謝謝!
由於tfsStore爲空,我仍然得到Exception「無法初始化TFS存儲」。謝謝! – JayHawk
呃...這段代碼在我身邊很好。此代碼是否成功連接到VSTS? –
是的。我能夠成功連接到VSTS。但是,它沒有實例化WorkItemStore。我想這不重要,因爲我能夠使用REST API來使代碼正常工作。謝謝! – JayHawk