0

这里 workItemStore 总是返回 null .....我希望将日志问题 tp TFS 作为一个小问题。但由于空异常无法这样做..帮助非常感谢...谢谢....

var networkCredential = new NetworkCredential(userName, password, domainName);

var credential = (ICredentials)networkCredential;

//Connect to TFS Project Collection, provide server URL in format http:// ServerName:Port/Collection


var tfs = new TfsTeamProjectCollection(
TfsTeamProjectCollection.GetFullyQualifiedUriForName(TfsConnectionUri), credential);

//Check whether valid TFS user or not

tfs.EnsureAuthenticated();

var workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

//Iterate Through Projects
    foreach (Project tfs_project in workItemStore .Projects)
    {
       Console.WriteLine(tfs_project.Name);

       //Perform WIQL Query 
       WorkItemCollection wic = wis.Query(
          " SELECT [System.Id], [System.WorkItemType],"+
          " [System.State], [System.AssignedTo], [System.Title] "+
          " FROM WorkItems " + 
          " WHERE [System.TeamProject] = '" + tfs_project.Name + 
          "' ORDER BY [System.WorkItemType], [System.Id]");
       foreach (WorkItem wi in wic)
       {
         Console.WriteLine(wi.Title + "["+wi.Type.Name+"]"+wi.Description);
       }
     }
4

2 回答 2

3

尝试以这种方式创建 WorkItemStore

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(TfsServerURI), nc); 
var _wis = new WorkItemStore(tfs);
于 2013-03-21T12:31:30.523 回答
1

不要将dll复制并粘贴到bin,您必须直接从路径添加引用:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll

它对我来说很有效。

于 2015-03-10T13:40:42.277 回答