When I am refreshing a databinding on a grid I am getting a;
A first chance exception of type 'System.ArgumentException' occurred in Infragistics2.Shared.v10.1.dll
A message box pops up that says "Key Already Exists Paramater Name: Key
The first time I set the databinding it works fine and show the rows, if i try to set it again it blows up. I have tried setting it to nothing first but that didnt work. Its just a simple refresh because the list its bound to may have added or removed rows.
How do I troubleshoot this?
MIke, you nailed it. I didnt realize the InitializeLayout fired everytime the datasource was set and It was trying to add a duplicate appearance.
You guys are awesome Thanks!
All my columns are added at design time. The service release did not fix it.
Call stack below.
"System.ArgumentException: Key already exists Parameter name: Key at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key, IKeyedSubObject ignoreObject) at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key) at Infragistics.Win.AppearancesCollection.Add(String key) at CMMS.UI.Scheduling.frmScheduleWeekly.grdWOs_InitializeLayout(Object sender, InitializeLayoutEventArgs e) in D:\CMMS\CMMS.UI\CMMS.UI\Scheduling\frmScheduleWeekly.vb:line 58 at Infragistics.Win.UltraWinGrid.UltraGrid.OnInitializeLayout(InitializeLayoutEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.FireInitializeLayout(InitializeLayoutEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ApplyLoadedBands() at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated() at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember) at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBindingHelper(Object dataSource, String dataMember, Boolean hideNewColumns, Boolean hideNewBands) at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember, Boolean hideNewColumns, Boolean hideNewBands) at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember, Boolean hideNewColumns) at CMMS.UI.Scheduling.frmScheduleWeekly.Fillform() in D:\CMMS\CMMS.UI\CMMS.UI\Scheduling\frmScheduleWeekly.vb:line 25 at CMMS.UI.Scheduling.frmScheduleWeekly.WoRemove() in D:\CMMS\CMMS.UI\CMMS.UI\Scheduling\frmScheduleWeekly.vb:line 200 at CMMS.UI.Scheduling.frmScheduleWeekly.RemoveFromScheduleToolStripMenuItem_Click(Object sender, EventArgs e) in D:\CMMS\CMMS.UI\CMMS.UI\Scheduling\frmScheduleWeekly.vb:line 205 at System.Windows.
Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.ToolStripDropDown.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at System.Windows.Forms.Form.ShowDialog() at CMMS.Exe.Startup.Main() in D:\CMMS\CMMS.EXE\CMMS.Exe\Startup.vb:line 29"
A FirstChanceException means that the exception is being caught in a try...catch block and you are only seeing it because you have set Visual Studio to break on all run-time exceptions.
Anyway, my guess is that the exception is occurring in your code in an event handler of the grid such as InitializeLayout. You are probably adding an unbound column or a summary or an Appearance when the grid is initialized and then not checking to see if it already exists before you add it again.
I could be wrong, of course. It would probably help a lot if you could post the entire call stack so we can see where the exception is coming from.
If you still get the error, there are some things that can cause that:
1. Using threading without safe invocation.
2. Adding columns manually.
3. Not using the latest service release. The last one was just released 5 days ago.
Can you post the call stack you get?
Besides, when a grid is bound to a list, then its set it to nothing, then you bind it to another list, it should not blow up.