【问题标题】:TFS WorkItems returns null alwaysTFS WorkItems 始终返回 null
【发布时间】:2013-03-21 11:21:37
【问题描述】:

这里 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);
       }
     }

【问题讨论】:

    标签: asp.net-mvc-3 c#-4.0 tfs


    【解决方案1】:

    尝试以这种方式创建 WorkItemStore

    TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(TfsServerURI), nc); 
    var _wis = new WorkItemStore(tfs);
    

    【讨论】:

    • 您好我试过上面的代码它说..“无法加载程序集 Microsoft.Teamfoundation.client.dll”..我使用的是 dll 版本 11...
    • 是啊!!!这是获取 WorkItemStore 的方法!使我免于头疼。非常感谢! +1
    • 谢谢。这种方式不是返回 null,而是得到一个异常来知道要修复什么。非常感谢
    • 我尝试使用上述代码,所以我遇到了错误,我知道我没有一些依赖项。谢谢
    【解决方案2】:

    不要把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
    

    它对我来说非常有效。

    【讨论】:

      猜你喜欢
      • 2013-04-04
      • 1970-01-01
      • 2016-05-31
      • 2015-08-15
      • 2012-03-18
      • 2016-11-04
      • 2016-07-28
      • 2010-11-08
      • 2017-11-26
      相关资源
      最近更新 更多