Hello,
We are experiencing an exception during the constructor of a form.
Error: 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 System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at Infragistics.Win.AppStyling.StyleUtilities.StyleHashtable`2.Add(TKey key, TValue value) at Infragistics.Win.AppStyling.StyleUtilities.UpdateRoleHierarchy(StyleHashtable`2 table, AssemblyStyleInfo[] assemblyInfos) at Infragistics.Win.AppStyling.StyleManager.ProcessLoadedAssembliesImpl() at Infragistics.Win.AppStyling.StyleManager.ProcessLoadedAssemblies() at Infragistics.Win.AppStyling.StyleManager.GetComponentProperties(String componentRoleName) at Infragistics.Win.AppStyling.StyleManager.ComponentStyleCache.GetProperties() at Infragistics.Win.AppStyling.StyleManager.PropertyInfoCache.ParseProperty(String propertyName) at Infragistics.Win.AppStyling.StyleManager.PropertyInfoCache.GetProperty(String propertyName) at Infragistics.Win.AppStyling.StyleManager.GetComponentPropertyValue(String componentRoleName, String propertyName) at Infragistics.Win.AppStyling.ComponentRole.GetProperty(String propertyName) at Infragistics.Win.UltraWinTabControl.StyleUtils.GetCustomPropertyValue(UltraControlBase ultraCtrl, CachedProperty prop, Object resolveVal) at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.get_ViewStyleResolved() at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.ResolveDefaultTabAppearance(UltraTab tab, TabState state, AppearanceData& appearance, AppearancePropFlags& requestedProps, Boolean resolvingPageArea) at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.ResolveDefaultTabAppearance(UltraTab tab, AppearanceData& appearance, AppearancePropFlags& requestedProps, Boolean resolvingPageArea) at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.ResolveDefaultTabAppearance(UltraTab tab, AppearanceData& appearance, AppearancePropFlags& requestedProps) at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.ResolveClientAreaAppearance(AppearanceData& appearance, AppearancePropFlags& requestedProps) at Infragistics.Win.UltraWinTabControl.UltraTabPageControl.get_BackColor() at System.Windows.Forms.Control.get_RenderTransparent() at System.Windows.Forms.Control.OnMove(EventArgs e) at System.Windows.Forms.Control.OnLocationChanged(EventArgs e) at Infragistics.Win.UltraWinTabControl.UltraTabPageControl.OnLocationChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.SetBounds(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.set_Location(Point value) at MyView.InitializeComponent() in D:\DOTNET\Local\MyView.Designer.vb:line 102 at MyView..ctor()
During application startup, a seperate thread is started where all views are preloaded. At the same time the constructor of the main form is called.
We suspect this is a threading issue and that the AppStyling is not completely thread safe.
Kind regards,
Michael
Hello ,
As far as I know Infragistics Component are not thread-safe, in fact DotNet controls are not thread-safe.
http://forums.infragistics.com/forums/p/28153/109410.aspx#109410
http://forums.infragistics.com/forums/p/49475/261653.aspx#261653
So my suggestion is to load your isl. file after you complete preloading of your views.
Please let me know if you have any further questions.
I do not agree, the DotNet controls are thread safe as long as you don't use the same control from within different threads. But if you have different threads each referencing a seperate controls, there won't be any problem.
The problem here is that the infragistics components are not thread safe even if seperate threads use seperate controls.
I'm not sure what you mean by "isl file", I don't know what that is, nor do I use that.
I just have seperate threads calling a constructors on seperate form's initializecomponent, and occasionally the exception mentionned is displayed.
Hi Michael,
Can you post a small sample project which reproduces the exception so we can check this out? It may be a bug in AppStyling.
Hey Mike,
I have so far been unable to reproduce this error with a sample application.
Does the exception itself provide any opportunity to track the problem or give me information under what conditions it could occur ?
I believe I have now resolved this issue.
Two different patch versions of the v11.1 DLLs were being loaded. When the second copy tried to initialize the style data, the exception was thrown.
Hristo,
I'm also seeing this issue. Stacktrace:
System.ArgumentException: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Infragistics.Win.AppStyling.StyleUtilities.StyleHashtable`2.Add(TKey key, TValue value)
at Infragistics.Win.AppStyling.StyleUtilities.UpdateRoleHierarchy(StyleHashtable`2 table, AssemblyStyleInfo[] assemblyInfos)
at Infragistics.Win.AppStyling.StyleManager.ProcessLoadedAssembliesImpl()
at Infragistics.Win.AppStyling.StyleManager.ProcessLoadedAssemblies()
at Infragistics.Win.AppStyling.StyleManager.GetSharedObjectProperties(String sharedObjectName)
at Infragistics.Win.AppStyling.StyleManager.SharedObjectCache.GetProperties()
at Infragistics.Win.AppStyling.StyleManager.PropertyInfoCache.ParseProperty(String propertyName)
at Infragistics.Win.AppStyling.StyleManager.PropertyInfoCache.GetProperty(String propertyName)
at Infragistics.Win.AppStyling.StyleManager.GetSharedObjectPropertyValue(ComponentRole componentRole, String sharedObjectName, String propertyName)
at Infragistics.Win.AppStyling.ComponentRole.GetProperty(String sharedObjectName, String propertyName)
at Infragistics.Win.UltraWinScrollBar.ScrollBarStyleInfo.get_ViewStyleResolved()
at Infragistics.Win.UltraWinScrollBar.ScrollBarUIElement.get_BorderStyle()
at Infragistics.Win.UIElement.get_RectInsideBorders()
at Infragistics.Win.UltraWinScrollBar.ScrollBarUIElement.PositionChildElements()
at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)
at Infragistics.Win.UltraWinTree.UltraTree.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
In this case, it happens when a drop-down custom control, containing other Infragistics elements (in this case, an UltraTextEditor, UltraDropDownButton, UltraPopupControlContainer and an UltraTree.
I'm not sure that I'll be able to produce a simple test case, sadly. However, if I can narrow down what's causing this, I'll let you know.
Hello,
I am just checking about the progress of this issue. Let me know If you need our further assistance on this issue?
Thank you for using Infragistics Components.
Thank you for your feedback.
Did you able to isolate your issue in a small sample, which we could investigate? Is there anything which I could do for you, which could help you to isolate this issue or any information which I could provide you?
I am waiting for your feedback.
Hey,
I was not able to solve the issue. I haven't managed to reproduce the problem in a sample application. With Mike's suggestions I can try again and work the other way around, starting from the current application and stripping it down to the bare essentials. However I currently don't have time to do that, maybe I will next week.
This issue is very important to us as we hope to help increase performance by preloading all the views in our applications. So I will defenitely keep testing till I can reproduce and track down this problem.