Exception: An entry with the same key already exists.

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Goran Bogdanovic - Software Development Engineer / Team Leader, ApexSQL LLC
Version: 4.0.0274
Platform: .NET 2.0
Environment: Windows XP (32-bit)

Recently we've begun experiencing the following exception quite frequently. It is usually linked to the "big red X" (drawing error) over the SyntaxEditor control:

Type:        System.ArgumentException
Message:     An entry with the same key already exists.
Source:      System
Stack Trace: at System.Collections.Specialized.ListDictionary.Add(Object key, Object value)
   at System.Collections.Specialized.HybridDictionary.Add(Object key, Object value)
   at bl.a(String A_0, Single A_1, Boolean A_2, Boolean A_3, Single A_4, Single A_5)
   at ActiproSoftware.SyntaxEditor.EditorView.a(PaintEventArgs A_0, Rectangle A_1, DocumentLine A_2, DisplayLine A_3, EditPositionRange A_4, Int32& A_5)
   at ActiproSoftware.SyntaxEditor.EditorView.OnRender(PaintEventArgs e)
   at ActiproSoftware.WinUICore.UIElement.Render(PaintEventArgs e)
   at ActiproSoftware.WinUICore.UIControl.OnRenderChildElements(PaintEventArgs e)
   at ActiproSoftware.WinUICore.UIControl.Render(PaintEventArgs e)
   at ActiproSoftware.WinUICore.UIControl.a(PaintEventArgs A_0)
   at ActiproSoftware.WinUICore.UIControl.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at ActiproSoftware.SyntaxEditor.SyntaxEditor.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
It is occurring in XP and Vista, both x86 and x64. We can however reproduce it only on multi-core CPU PCs.

Unfortunately, I cannot share any code right now to reproduce the issue, but I can say that we are extensively using multithreading to load some custom tokens / make changes to Language. We are careful to always use the Language.IsUpdating and to assign the new Language to an existing Document in the worker UI thread.

Based on several similar "big red X" exception posts, I believe this is related to multithreaded usage of the SyntaxEditor Document or Language. I'm just wondering if you've found and fixed the error based on the above exception call stack by now in the latest build (281) or if you have any suggestions on how we should approach the issue on our side?


Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA

Sorry but at this time it probably is not safe to alter the language on anything but the main UI thread. My recommendation would be to maybe do the work of determining what needs to update on your worker thread, pass that data back to the main UI thread, and update the actual language objects there. That should prevent these issues.

Actipro Software Support

The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.