Import DCTX throws error System.ArgumentException: An item with the same key has already been added

I have a very large DCT and I import from a DCTX and it is fine. If I close the DCT and then reopen it I get this error.

It seems this is the issue, but I have searched the DCTX for duplicate Table GUIDs and also Alias GUIDs and Key GUIDs and could not find anything. Any thoughts on how to narrow the issue?

   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)

It is a very large DCT

TABLECNT     : 157
COLUMNCNT    : 8857
KEYCNT       : 2466
ALIASCNT     : 1454
RELATIONCNT  : 1784
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at SoftVelocity.DataDictionary.UniqueDataDictionaryItemList`1.Add(String name, T newItem)
   at SoftVelocity.DataDictionary.UniqueDataDictionaryItemList`1.Add(T newItem)
   at SoftVelocity.DataDictionary.FieldContainer.AddField(Record r, DDBaseFile file, DataDictionaryItem parent, FieldsFile fields, UniqueDataDictionaryItemList`1 items)
   at SoftVelocity.DataDictionary.FieldContainer.InitFields(DataDictionaryItem parent, UniqueDataDictionaryItemList`1 items)
   at SoftVelocity.DataDictionary.DDBaseFile.InitFields()
   at SoftVelocity.DataDictionary.BaseDataDictionaryItemList`1.InitList()
   at SoftVelocity.DataDictionary.BaseDataDictionaryItemList`1.ForceInit()
   at SoftVelocity.DataDictionary.BaseDataDictionaryItemList`1.System.Collections.IEnumerable.GetEnumerator()
   at Aga.Controls.Tree.TreeViewAdv.ReadChilds(TreeNodeAdv parentNode, Boolean performFullUpdate)
   at Aga.Controls.Tree.TreeViewAdv.AddNode(TreeNodeAdv parent, Int32 index, TreeNodeAdv node)
   at Aga.Controls.Tree.TreeViewAdv.ReadChilds(TreeNodeAdv parentNode, Boolean performFullUpdate)
   at Aga.Controls.Tree.TreeViewAdv._model_StructureChanged(Object sender, TreePathEventArgs e)
   at SoftVelocity.DataDictionary.Editor.DataDictionaryTreeView.OnStructureChanged()
   at SoftVelocity.DataDictionary.Editor.DataDictionaryTreeView.RefreshList()
   at SoftVelocity.DataDictionary.Editor.DataDictionaryTreeView.Refresh(DataDictionaryItem parentItem)
   at SoftVelocity.DataDictionary.Editor.DataDictionaryTreeView.Init(DataDictionaryItem item, DCTContent content, EntityBrowserDetails defaultDetails)
   at SoftVelocity.DataDictionary.Editor.EntityBrowser.Init(DCTContent contentManager, DDLabeledItem ddItem)
   at SoftVelocity.DataDictionary.Editor.EntityBrowser.SoftVelocity.DataDictionary.Editor.IQuickDetail.Initialize(DCTContent contentManager, DDLabeledItem ddItem)
   at SoftVelocity.DataDictionary.Editor.DCTContent.ShowQuickView(DDLabeledItem parentItem, Boolean first)
   at SoftVelocity.DataDictionary.Editor.DCTExplorer.OnDCTExplorerLoad(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   at WeifenLuo.WinFormsUI.DockContentHandler.SetVisible()
   at WeifenLuo.WinFormsUI.DockPane.set_ActiveContent(IDockContent value)
   at WeifenLuo.WinFormsUI.DockPane.ValidateActiveContent()
   at WeifenLuo.WinFormsUI.DockContentHandler.SetDockState(Boolean isHidden, DockState visibleState, DockPane oldPane)
   at WeifenLuo.WinFormsUI.DockContentHandler.set_DockState(DockState value)
   at WeifenLuo.WinFormsUI.DockContentHandler.Show(DockPanel dockPanel, DockState dockState)
   at WeifenLuo.WinFormsUI.DockContentHandler.Show(DockPanel dockPanel)
   at WeifenLuo.WinFormsUI.DockContent.Show(DockPanel dockPanel)
   at SoftVelocity.DataDictionary.Editor.DCTContent.DCTContent_Load(Object sender, EventArgs e)
   at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
   at System.Windows.Forms.UserControl.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   at WeifenLuo.WinFormsUI.DockContentHandler.SetVisible()
   at WeifenLuo.WinFormsUI.DockPane.set_ActiveContent(IDockContent value)
   at WeifenLuo.WinFormsUI.DockContentHandler.Activate()
   at WeifenLuo.WinFormsUI.DockContentHandler.Show(DockPanel dockPanel, DockState dockState)
   at WeifenLuo.WinFormsUI.DockContentHandler.Show(DockPanel dockPanel)
   at WeifenLuo.WinFormsUI.DockContent.Show(DockPanel dockPanel)
   at ICSharpCode.SharpDevelop.Gui.SdiWorkbenchLayout.ShowView(IViewContent content)
   at ICSharpCode.SharpDevelop.Gui.DefaultWorkbench.ShowView(IViewContent content)
   at ICSharpCode.SharpDevelop.FileService.LoadFileWrapper.Invoke(String fileName)
   at ICSharpCode.Core.FileUtility.LoadWrapper.Invoke()
   at ICSharpCode.Core.FileUtility.ObservedLoad(FileOperationDelegate loadFile, String fileName, String message, FileErrorPolicy policy)

The problem occurs on processing files fields obviously.

I have dumped all the field guids and no duplicates

The call stack gives no clue which a field is causing the problem. DCTX is required.

Sounds, fields names are duplicating.

After breaking my DCT down bit by bit and reimporting and comparing the new DCTX files I found the issue. (at least in my case)

I am importing, manipulating and generating a DCTX file which I then import.

(The code below does not have the surrounding <> because for some reason it would not show up below)

I was generating…
Table Guid=“{4d453959-434e-5632-454e-344c4355414c}” Usage=“Global” Name=“GlobalTableSupport” Prefix=“GTS” Description=“Table Support Fields”

The CW Export was generating… (Notice PREFIX= is at then End)
Table Guid=“{4d453959-434e-5632-454e-344c4355414c}” Usage=“Global” Name=“GlobalTableSupport” Description=“Table Support Fields” Prefix=“GTS”

Also I was not generating an AUDIT line
Audit CreateUser=“Administrator” CreateDate=“27 APR 2024” CreateTime=" 2:16:36PM" CreateVersionNumber=“1” ModifiedUser=“Administrator” ModifiedDate=“27 APR 2024” ModifiedTime=" 2:17:19PM" ModifiedVersionNumber=“1”/

When I corrected these 2 things I can Import the DCTX close the DCT and reopen it w/o Issue.

I am not sure why this was such an issue, but these two things corrected my issue.

Thank you to everyone’s help/thoughts/suggestions.

The < and > are used to embed HTML in the Markdown. To use < > you have to format as Code by surrounding with single backticks, or have 3 backticks on the line above and below. e.g. your DCTX line

<Table Guid=“{4d453959-434e-5632-454e-344c4355414c}” Usage=“Global” Name=“GlobalTableSupport” Prefix=“GTS” Description=“Table Support Fields” >

Note that once you save without the backticks as CODE the quotes are converted to Typesetter 93h 94h as seen above, versus the correct code 22h "quotes" below:

<Table Guid="{4d453959-434e-5632-454e-344c4355414c}" Usage="Global" Name="GlobalTableSupport"... >


3 backticks above and below (I fixed “quotes”):

<Table Guid="{4d453959-434e-5632-454e-344c4355414c}" Usage="Global" Name="GlobalTableSupport" Description="Table Support Fields" Prefix="GTS">

An alternative for fixed width font is to wrap it in the HTML tags <pre> ... </pre> but that is not going to work to surround XML that uses < ... >. It’s good for a CSV file.

TABLECNT     : 157
COLUMNCNT    : 8857
KEYCNT       : 2466
ALIASCNT     : 1454
RELATIONCNT  : 1784

This screen capture shows the Editor on the Left with Markup backticks and Preview on the Right with < >

2 Likes

Oh, OK - I was just too tired to look it up - thanks as usual Carl for your insights - I love learning :wink:

When I was playing around with writing DCTX I did find that ordering of attributes made a difference in some circumstances. I opted to write stuff in the same order as Clarion did mostly just so that I could check that what I generated was the same as what Clarion generated – I was transferring the DCTX info to a SQLite database, modifying it and writing it back.

I don’t think I ever found missing Audit lines to be a problem.

1 Like