Hi,
I'm trying to bind the DataSource of UltraWingrid to a custom dataset, which caused two NullReferenceExceptions being thrown in the Infragistics code. I'm haveing trouble to reproduce the exceptions as they are only thrown occationally.
Please kindly advise how this can be resolved.
Code:
private
{ //.....
productTypesFilterGrid.DataSource = productTypes;
Exception 1:
System.NullReferenceException: Object reference not set to an instance of an object. 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.set_DataSource(Object value) at ......\src\Assemblies\AccountSearch.SmartParts\AccountSearchSettingsNew.cs:line 222
Exception 2:
System.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Win.UltraWinGrid.RowsCollection.InternalClearHelper() 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.set_DataSource(Object value) at ......\src\Assemblies\AccountSearch.SmartParts\AccountSearchSettingsNew.cs:line 222
Thanks and Regards,
Tess
If the exceptions are only thrown occasionally, this sounds like an issue that might be caused by the use of threading; you need to make absolutely certainly that any actions that may affect the UI (which includes binding the grid or modifying the data source that the grid, or any UI component is bound to), is modified on the main UI thread.
-Matt
Hi Matt,
Thanks for your reply. The thread is actually switched back to the main UI thread before InitializeSettings is called.
void
IAccountSearchSettings.InitializeSearchSettings(ProductFamilyFilterDataSet productTypes)
{
if (InvokeRequired)
BeginInvoke(
new InitializeSettingsCallback(InitializeSettings), new object[] { productTypes });
}
else
InitializeSettings(productTypes);
Can it be the problem of the custom dataset?
Thanks,
I don't see why a custom dataset would cause a NullReferenceException in the grid's code. Perhaps your threading code is expecting all the grid initialization to occur before it continues (i.e. the InitializeSearchSettings method is returning and some other code is expecting the grid to be in a valid state). Since BeginInvoke will occur asynchronously, perhaps you should try a straight Invoke instead so that the marshalling occurs synchronously. You may want to take a look at this article as well.