I am working on a clients application that is using CSLA Assembly Version 2.0.3.0. The error I am getting is
System.ArgumentOutOfRangeException was unhandled by user code
HResult=-2146233086
Message=Specified argument was out of the range of valid values.
Parameter name: rowIndex
Source=System.Windows.Forms
ParamName=rowIndex
StackTrace:
at System.Windows.Forms.DataGridView.InvalidateCell(Int32 columnIndex, Int32 rowIndex)
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.Child_PropertyChanged(Object sender, PropertyChangedEventArgs e)
at Csla.Core.BindableBase.OnPropertyChanged(String propertyName) in C:\WOFCOCollection\MPS\Main\WinApps\GUI\Csla203\Core\BindableBase.cs:line 99
at Csla.Core.BusinessBase.PropertyHasChanged(String propertyName) in C:\WOFCOCollection\MPS\Main\WinApps\GUI\Csla203\Core\BusinessBase.cs:line 253
at Csla.Core.BusinessBase.PropertyHasChanged() in C:\WOFCOCollection\MPS\Main\WinApps\GUI\Csla203\Core\BusinessBase.cs:line 236
at JmFamily.Mps.Entities.MPSDYN03.Wmps02900d.set_ClientNbr(String value) in C:\WOFCOCollection\MPS\Main\WinApps\GUI\JMFamily.Entity\MPSDYN03\Wmps02900d.cs:line 665
at JMFamily.Mps.W_wmps_029.dw_detl_ue_select_ovl() in C:\WOFCOCollection\MPS\Main\WinApps\GUI\Mps\Mpsbe\W_wmps_029.cs:line 11261
at JMFamily.Mps.W_wmps_029.dw_detl_rowfocuschanged(Object sender, EventArgs e) in C:\WOFCOCollection\MPS\Main\WinApps\GUI\Mps\Mpsbe\W_wmps_029.cs:line 13515
at Metex.Core.DataUserControl.OnRowFocusChanged(EventArgs e) in C:\WOFCOCollection\MPS\Main\WinApps\GUI\Metex.Core\DataUserControl.cs:line 753
at Metex.Core.DataUserControl.RaiseRowFocusChangedEvent(Object sender, EventArgs e) in C:\WOFCOCollection\MPS\Main\WinApps\GUI\Metex.Core\DataUserControl.cs:line 828
at System.Windows.Forms.BindingSource.OnCurrentChanged(EventArgs e)
at System.Windows.Forms.BindingSource.CurrencyManager_CurrentChanged(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnCurrentChanged(EventArgs e)
InnerException:
nonSerializableHandlers.Invoke(this,
new PropertyChangedEventArgs(propertyName));
The code that causes this error follows
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler nonSerializableHandlers = _nonSerializableHandlers;if (nonSerializableHandlers != null )
nonSerializableHandlers.Invoke(this, new PropertyChangedEventArgs(propertyName));
PropertyChangedEventHandler serializableHandlers = _serializableHandlers;if (serializableHandlers != null)
serializableHandlers.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
The propertyName parameter happens to be "ClientNbr" and when I look at the object reference by "this" it does contain a property named "ClientNbr". I cannot figure out why this error is occuring. The object uses a bindingSource.
Is this a known bug?. The PropertyHasChanged method is working correctly in countless other examples in the application but in this particular case there are three properties that are being changed on this object and they all have the same error.
Thanks
Hi,
The data binding exceptions can be deceiving. The exception is thrown from the GridView and it has a "foaulty" rowindex for a changed item. So the issue is not with the PropertyChanged event as such. The issue is with the list and the datagrid view.
Is the list wrapped in a Sorted/Filtered binding list. There is quite a few bugfixes done in later years to these classes to send the correct listindex back to the UI control on the ListChanged event.
To debug further I would put a breakpoint into the OnListChanged event on the list and look at which RowIndex is causing the issue.
So just to be clear - this is NOT a bug in PropertyChanged event on the item.
It _may_ be a bug in how the list is determining the ListIndex of the item and use this index for OnListChanged event or a bug in some event code on the UI control/DataGridView.
JohhyBee,
Apparently you are in Norway. If I were anywhere close I would turn the world upside down to buy you dinner. You were absolutely right about the problem being with the grid. The actual problem was the when the CSLA object property was being changed the current grid row was actually null. This application has all kinds of clever event handling and the code in question was being executed when it should not have been. I surrounded the code in question with an if block testing for a null current grid row and it fixed the problem. The code is being executed twice which points to other issues but the app is functioning without the previous error. They were in staging with a bunch of changes and this bug cropped up on code that had not been modified. Big puzzle. So you my friend are my new hero.
Thanks Loads.
Copyright (c) Marimer LLC