这里workItemStore总是返回null .....我想要日志问题tp TFS作为一个小块。但是无法做到这样的空例外becoz ..帮助非常感谢...谢谢....
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);
}
}
答案 0 :(得分:3)
以这种方式尝试创建WorkItemStore
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(TfsServerURI), nc);
var _wis = new WorkItemStore(tfs);
答案 1 :(得分: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
它完全适合我。