我尝试按照此方法查询Team Foundation Server:
https://msdn.microsoft.com/library/bb130306.aspx
这就是我所拥有的
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
new Uri("http://server:8080/tfs/DefaultCollection"));
WorkItemStore workItemStore = (WorkItemStore)tpc.GetService (typeof(WorkItemStore));
// Run a query.
WorkItemCollection queryResults = workItemStore.Query(
"Select [State], [Title] " +
"From WorkItems " );
// Run a saved query.
QueryHierarchy queryRoot = workItemStore.Projects[0].QueryHierarchy;
QueryFolder folder = (QueryFolder)queryRoot["Shared Queries"];
QueryDefinition query = (QueryDefinition)folder["Active Bugs"];
queryResults = workItemStore.Query(query.QueryText);
//}
我收到错误:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in Microsoft.TeamFoundation.WorkItemTracking.Client.dll
Additional information: Specified argument was out of the range of valid values.
我添加了一个catch异常,我收到了这个错误:
Specified argument was out of the range of valid values.
Parameter name: index.
答案 0 :(得分:1)
您的workItemStore.Projects必须为空或null。