我正在尝试修改工作项字段并以务实的方式启动它。 下面是代码
ICredentials credentials = new NetworkCredential("user", "paswd", "domain");
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("path "), credentials);
WorkItemStore workItemStore = (WorkItemStore)tfs.GetService<WorkItemStore>();
WorkItemTypeCollection workItemTypes = workItemStore.Projects["project"].WorkItemTypes;
WorkItemType workItemType = workItemTypes["Bug"];
var workItem = new WorkItem(workItemType)
{
Title = "Test",
};
workItem.Fields["Microsoft.VSTS.Common.Priority"].Value = "2";
workItem.Description = "New Description";
documentService = (DocumentService)_applicationObject.DTE.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService");
var a = new object();
IWorkItemDocument workItemDocument = documentService.CreateWorkItem(workItem, a);
(Throws exception : "Object reference not set to an instance of an object." in above line)
documentService.ShowWorkItem(workItemDocument);
请建议如何处理异常
谢谢和问候, 钱德拉