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
Hi,
I just wanted to know if you were able to solve your issue based on Mike's suggestions or you still need help? Just let me know.
Thank you.
Hi Michael,
The exception definitely seems to indicate a threading problem.
Exception like this often occur when there is a static member variable which is not thread static. So the same member is accessed by multiple threads.
I took a look at the method where the exception is occurring and it's a static method, but the dictionary being used there is a local variable and is not static. So I don't see anything obvious here that would cause a problem like the one you are having.
The reality is, if we cannot duplicate the problem, there's really not much we can do. Even if we took a guess, there's no way we could even know if we actually fixed it or not.
If you cannot reproduce the issue by creating a new sample and working upward from there, maybe you can take the opposite approach. Make a copy of your real project and try to reduce it down to the bare essentials so you could post something here that we could run.
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 ?
Can you post a small sample project which reproduces the exception so we can check this out? It may be a bug in AppStyling.
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.