0

ここでworkItemStoreは常にnullを返します...私は問題をログに記録したいtp TFSをナグとして. しかし、null例外のためにそうすることができません..ヘルプは非常に高く評価されています...ありがとう....

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 に答える