我正在尝试通过WEB API向TFS“ONLINE”提交workItem。它在我的本地机器上工作正常,但是当我将它上传到共享主机服务器时,它无法正常工作。
发生了错误。 错误HRESULT E_FAIL已从调用COM组件返回。 System.Runtime.InteropServices.COMException Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.Datastore.UpdateMetadata(Object rowset,String dbstamp)at at Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.DataStoreNative.UpdateMetadata(IntPtr handle,Object rowset,String dbstamp,UInt32& changes)at at Microsoft Microsoft.TeamFoundation上的Microsoft.TeamFoundation.WorkItemTracking.ClientFore.WorkItemTracking.WorkItemStore.InitializeInternal()中的Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.RefreshCacheInternal(BackendCallData& data)中的Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.EndBackendCall(BackendCallData数据) Microsoft.TeamFoundation.Client.TfsConnection.CreateServiceInstance(程序集程序集)中的Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.InitializeTeamFoundationObject(String fullName,Object instance)的.WorkItemTracking.Client.WorkItemStore.Microsoft.TeamFoundation.Client.ITfsTeamProjectCollectionObject.Initialize(TfsTeamProjectCollection teamProjectCollection) ,String fullNam e)位于Microsoft.TeamFoundation.Clits.TfsConnection.GetService的Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.GetServiceInstance(类型serviceType,Object serviceInstance)中的Microsoft.TeamFoundation.Client.TfsConnection.GetServiceInstance(类型serviceType,Object serviceInstance)(类型serviceType)位于e:\ Industry \ InsightSoft \ FeedBack \ FeedBackService \ FeedBackService \ Models \ TFSManager.cs:第249行的FeedBackService.Models.TFSManager.AddWorkItem(字符串标题,字符串描述,字符串imagePath)中的Microsoft.TeamFoundation.Client.TfsConnection.GetServiceT位于e:\ Industry \ InsightSoft \ FeedBack \ FeedBackService \ FeedBackService \ Controllers \ ValuesController.cs中的FeedBackService.Controllers.ValuesController.Get():位于System.Web.Http的lambda_method(Closure,Object,Object [])的第28行。 Systems.Web.Http.Controllers.ReflectedHttpActionDescriptor中的Controllers.ReflectedHttpActionDescriptor.ActionExecutor。<> c_ DisplayClass13.b _c(Object instance,Object [] methodParameters)。在System.Threading.Tasks.TaskHelpers的System.Web.Http.Controllers.ReflectedHttpActionDescriptor。<> c_ DisplayClass5.b _4()的ActionExecutor.Execute(Object instance,Object [] arguments)。 RunSynchronously [TResult](Func`1 func,CancellationToken cancellationToken)
我的代码:
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(); } }
答案 0 :(得分:2)
我有同样的错误,虽然我正在研究内部TFS。清除以下文件:
C:\ ProgramData \ Microsoft Team Foundation \ 4.0 \ Cache
我连接到TFS的地方解决了我的问题。