我正在尝试通过 WEB API 将 workItem 提交到 TFS“ONLINE”。它在我的本地机器上运行良好,但是当我将它上传到共享托管服务器时它不起作用。
发生了错误。对 COM 组件的调用已返回错误 HRESULT E_FAIL。Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.Datastore.UpdateMetadata(Object行集,字符串 dbstamp) 在 Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.EndBackendCall(BackendCallData 数据) 在 Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.RefreshCacheInternal(BackendCallData& 数据) 在 Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.InitializeInternal( ) 在 Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.Microsoft.TeamFoundation.Client.ITfsTeamProjectCollectionObject。DisplayClass13.b _c(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c_ DisplayClass5.b _4() 在 System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancelToken)
我的代码:
public void AddWorkItem(string title,string description,string imagePath) { string _myUri = "https://testredrock.visualstudio.com/DefaultCollection"; NetworkCredential netCred = new NetworkCredential(userName, password); BasicAuthCredential basicCred = new BasicAuthCredential(netCred); TfsClientCredentials credential = new TfsClientCredentials(basicCred); credential.AllowInteractive = false; string TFSServerPath = "https://testredrock.visualstudio.com/DefaultCollection"; using (TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(TFSServerPath), credential)) { CatalogNode catalogNode = tfs.CatalogNode; ReadOnlyCollection<CatalogNode> tpNodes = catalogNode.QueryChildren( new Guid[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); WorkItemStore workItemStore = tfs.GetService<WorkItemStore>(); Project teamProject = workItemStore.Projects[project]; WorkItemType workItemType = teamProject.WorkItemTypes[workitemType]; // Create the work item. WorkItem userStory = new WorkItem(workItemType) { // The title is the only required field that does not have a default value. // You must set it, or you cannot save the work item. Title = title, Description = "", }; userStory.Fields["Repro Steps"].Value = description; // Save the new user story. userStory.Save(); } }