Hello. I have several grids bound to various different datasources, all of which use the Excel exporting functionality. However, one of the grids encounters an error every time I try to perform an Excel export. For this particular grid, it is bound directly to a typed DataTable in a typed DataSet, without a BindingSource. There is one unbound column in the grid. Below is the exception:
System.ArgumentException: Key already existsParameter name: Key at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key, IKeyedSubObject ignoreObject) at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key, IKeyedSubObject ignoreObject) at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key) at Infragistics.Shared.KeyedSubObjectsCollectionBase.InternalAdd(IKeyedSubObject obj) at Infragistics.Win.UltraWinGrid.ColumnsCollection.InternalAdd(UltraGridColumn column) at Infragistics.Win.UltraWinGrid.UltraGridBand.InitColumns(UltraGridBand[] oldBands) at Infragistics.Win.UltraWinGrid.UltraGridBand.InitListManager(BindingManagerBase bindingManager, String dataMember, UltraGridBand[] oldBands) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated() at Infragistics.Win.UltraWinGrid.UltraGrid.Export(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, Worksheet worksheet, Int32 startRow, Int32 startColumn) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, Workbook workbook) at MyApp.WinForms.Controls.BaseControl.ExportGrid(UltraGrid grid, String title, String initDirectory, Boolean promptToOpen) in D:\Development\MyApp\MyApp.WinForms\Controls\BaseControl.cs:line 882
I am using Infragistics v10.2. Any insight or help you can provide would be greatly appreciated.
Thanks!
Hi,
I'm using the latest version 2014.1 and I'm getting the same error....
I have no unbound columns, I'm not adding any columns at run time and the grid is in a basic design (I just added the grid and set datasource and datamember, I didn't change anything else to the design)
I'll make a sample application if I can find the time.
Best Regards,
Peter
Hi Mia,
When you say "it loaded the grid fine, without errors", are you saying that you didn't get any exception at all? Or do you mean that it didn't reveal any new exceptions, but the original one is still occurring?
Either way, there's not much else we can do without being able to see the issue.
The only other thing that comes to mind is threading. Are you using multiple threads in your application? That could certainly cause an issue like this.
Can you duplicate this exception in a small sample project and post it here so we can check it out?If so, I'd be happy to take a look.
Other than that, the only thing I can think to recommend is that you download the latest service release and see if that helps. I've never heard of this error message before, though, so it seems unlikely that it would make a difference.
Okay, so I set VS to break on all exceptions and it loaded the grid fine, without errors, the only exception it's breaking on is where I call ultraGridExcelExporter.Export(UltraGrid grid, Workbook excelWorkbook).
Good morning, Mike. I appreciate your prompt response!!
The unbound column is added through the designer, but the value of it is set using an InitializeRow event handler. I have tried removing the unbound column completely and removing the InitializeRow event handler subscription, but still the error persists.
Another interesting tidbit -- the error also occurs when trying to print the same grid. The error callstack is similar -- except that it starts in the UltraGrid.Print(UltraGridLayout layout, PrintDocument printDocument, RowPropertyCategories retainRowPropertyCategories) method.
I will try changing the VS settings and see if I can get more details out of this.
Mia
From the call stack, it appears that the exception occurs when the grid is trying to bind the export layout to the same data source that the real grid is bound to. Which is very odd, since I assume the actual on-screen grid doesn't have any problems like this.
My best guess is that something in your code is trying to re-add the unbound column into the export layout even though it already exists. Are you adding your unbound column in code? If so, what event are you using?
Try setting the Visual Studio IDE to break on all run-time exceptions. I'm guessing that the call stack you have here is not really the problem, but that the real exception is occurring and being caught somewhere else.