0

ディクショナリに値が見つからなかったことを示すこの例外「指定されたキーがディクショナリに存在しませんでした」で立ち往生していますが、奇妙なことに、ディクショナリを使用していません。内部コードだと思いますC# の TFS API の。例外を発生させるコードの一部を次に示します。

if (wi.Validate().Count == 0)
{
     // Save the work item to submit changes
     wi.Save();
}
else
{
     Console.WriteLine("following errors was encountered when trying to save the work          item {0} : ", id);
     foreach (var e in wi.Validate())
                        {
           Console.WriteLine(" - '{0} '", e);
     }
}


                    // Close the work item
                    wi.Close(); 

                    // Submit the changes to the database
                    SubmitChangesToDatabase(id, author, statusChanged, previousChangeTime);  

                    // Open again the work item to go on with other updates
                    wi.Open();

このコードは、作業項目を取得し、TFS API を使用していくつかの更新を実行するループの一部です。その後、メソッドSubmitChangesToDatabaseを使用してデータベースの読み取り専用フィールドを直接変更します。メソッドOpen()を呼び出すと、例外が発生します。スタック トレースは次のとおりです。

System.Collections.Generic.KeyNotFoundException was unhandled
  HResult=-2146232969
  Message=The given key was not present in the dictionary.
  Source=mscorlib
  StackTrace:
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Microsoft.TeamFoundation.WorkItemTracking.Internals.WorkItemHelper.FindRevisionIndexByDate(Int32 trackTimeFieldId, List`1 revisions, Dictionary`2 latestData, DateTime dt, Int32 startIndex)
       at Microsoft.TeamFoundation.WorkItemTracking.Internals.WorkItemHelper.LoadWorkItemFieldData(IRowSetCollectionHelper tables, IWorkItemOpenFieldDataHelper helper)
       at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem.LoadWorkItemFromRowSetInternal(Int32 rev, Nullable`1 asof, IWorkItemRowSets witem)
       at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem.LoadWorkItem(Int32 id, Int32 rev, Nullable`1 asof)
       at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem.Open()
       at CSVToTFS.TFSServer.SetWorkItemHistory(Int32 id, DataTable ticketChange) in d:\Documents\Visual Studio 2013\Projects\TFS\CSVToTFS\TFSServer.cs:line 253
       at CSVToTFS.Program.Main(String[] args) in d:\Documents\Visual Studio 2013\Projects\TFS\CSVToTFS\Program.cs:line 173
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
4

1 に答える 1

0

チーム プロジェクトが Aeea パスの代わりにチーム フィールドを使用するように構成されているときに、これが発生しました。これを変更し、一部の作業項目にまだチームが指定されていない場合、このエラーが発生します。

「yourteamfield.team」を空に設定してクエリを作成し、すべての作業項目を一括更新して値を持つようにすると、エラーは解消されます。

于 2014-06-29T10:34:18.833 に答える