I am having the following error in following code while trying to get workitem store
. I searched everywhere but i couldn't find any solution please help :(
TF31002: Unable to connect to this Team Foundation Server: http:
Team Foundation Server Url: http:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Common;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace ModifyWorkItems
{
public static class CWorkItems
{
public static void RemoveAllWorkItems()
{
List<workitem> workItems = new List<workitem>();
try
{
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("http://hostname:8080/tfs/tpCollectionName/tpname/"));
// WorkItemStore store = tfs.GetService<workitemstore>();
// TeamFoundationServer tfs = new TeamFoundationServer("http://hostname:8080/tfs/tpCollectionName/tpname/");
// WorkItemStore m_store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
WorkItemStore store = new WorkItemStore(tfs);
string wiql = "SELECT ID FROM WorkItems WHERE ([Work Item Type]='Task' OR [Work Item Type]='User Story' OR [Work Item Type]='Bug') AND [State] <>'Closed' AND [AreaPath] <> '/Entegrasyon' ";
WorkItemCollection wicr = store.Query(wiql);
foreach (WorkItem wi in wicr)
{
wi.Open();
wi.Fields["State"].Value = "Removed";
wi.Save();
wi.Close();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}