Controls databound to Related Fields throw ArgumentOutOfRangeException

Posts   
 
    
Dusty
User
Posts: 24
Joined: 19-Feb-2008
# Posted on: 24-Jun-2011 15:27:42   

Version: LLBLGen Pro v3.1 Final (June 17th, 2011) Target Framework: LLBLGen Pro Runtime Framework Target Platform: .NET 4.0 Template Group: SelfServicing - General2010 (With additional custom templates)

I am migrating WinForms projects from v2.6 & .NET 3.5 to v3.1 & .NET 4.0 I've gotten everything to build and validated all my method signatures.

I am having an issue with controls bound to child entity related fields.

My main entity in this example is an OrderHeader which has a related collection of OrderDetail entities called OrderDetails. OrderDetail has related fields PartDescription (Part.Description) and PartRevisionDescription (PartRevision_.Description). My form has BindingSources (orderHeaderEntityBindingSource.DataSource = typeof(OrderHeaderEntity)) and (orderDetailBindingSource.DataSource = orderHeaderEntityBindingSource; orderDetailBindingSource.DataMember = "OrderDetails").

Everything bound to orderHeaderEntityBindingSource binds fine. orderDetailBindingSource is bound to a DataGridView and several other UI controls. I have two TextBox controls bound to (orderDetailBindingSource - PartDescription) and (orderDetailBindingSource - PartRevisionDescription). When the form loads in debug mode I get an ArgumentOutOfRangeException on this code:


        /// <summary> setups the sync logic for member _partRevision_</summary>
        /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
        private void SetupSyncPartRevision_(IEntity relatedEntity)
        {
            if(_partRevision_!=relatedEntity)
            {       
                DesetupSyncPartRevision_(true, true);
                _partRevision_ = (PartRevisionEntity)relatedEntity;
                this.PerformSetupSyncRelatedEntity( _partRevision_, new PropertyChangedEventHandler( OnPartRevision_PropertyChanged ), "PartRevision_", ABS.BusinessObjects.RelationClasses.StaticOrderDetailRelations.PartRevisionEntityUsingPartNumberPartRevisionStatic, true, ref _alreadyFetchedPartRevision_, new string[] { "PartRevisionDescription" } );  // ArgumentOutOfRangeException HERE!!!
            }
        }
        
        /// <summary> setups the sync logic for member _part</summary>
        /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
        private void SetupSyncPart(IEntity relatedEntity)
        {
            if(_part!=relatedEntity)
            {       
                DesetupSyncPart(true, true);
                _part = (PartEntity)relatedEntity;
                this.PerformSetupSyncRelatedEntity( _part, new PropertyChangedEventHandler( OnPartPropertyChanged ), "Part", ABS.BusinessObjects.RelationClasses.StaticOrderDetailRelations.PartEntityUsingPartNumberStatic, true, ref _alreadyFetchedPart, new string[] { "PartDescription" } );  // ArgumentOutOfRangeException HERE!!!
            }
        }

If I suspend binding on orderDetailBindingSource before the orderHeaderEntityBindingSource.DataSource is set I get no error. If I remove the TextBox control bindings for PartDesctipion and PartRevisionDescription I get no error. I had no issues with this in v2.6 and .NET 3.5.

Help me! Help me, please please please!!!cry

Exception Details: System.ArgumentOutOfRangeException was unhandled by user code 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.GetCellDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow) at System.Windows.Forms.DataGridView.GetCellAdjustedDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow) at System.Windows.Forms.DataGridView.InvalidateCellPrivate(Int32 columnIndex, Int32 rowIndex) at System.Windows.Forms.DataGridView.OnCellCommonChange(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.ListItem_PropertyChanged(Object sender, EventArgs e) at System.ComponentModel.PropertyDescriptor.OnValueChanged(Object component, EventArgs e) at System.ComponentModel.ReflectPropertyDescriptor.OnValueChanged(Object component, EventArgs e) at System.ComponentModel.ReflectPropertyDescriptor.OnINotifyPropertyChanged(Object component, PropertyChangedEventArgs e) at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e) at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.OnPropertyChanged(String propertyName) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityBase.cs:line 2245 at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.PerformSetupSyncRelatedEntity(IEntity relatedEntity, PropertyChangedEventHandler propertiesChangedHandler, String fieldName, IEntityRelation relation, Boolean connectToSaveEvent, Boolean& alreadyFetchedFlag, String[] forfNames) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityBase.cs:line 3532 at ABS.BusinessObjects.EntityClasses.OrderDetailEntity.SetupSyncPartRevision(IEntity relatedEntity) in D:\CSD Projects\ABS_Manufacturing\ABS_Manufacturing_Source\ABS.BusinessObjects\EntityClasses\OrderDetailEntity.cs:line 1137 at ABS.BusinessObjects.EntityClasses.OrderDetailEntity.SetRelatedEntity(IEntity relatedEntity, String fieldName) in D:\CSD Projects\ABS_Manufacturing\ABS_Manufacturing_Source\ABS.BusinessObjects\EntityClasses\OrderDetailEntity.cs:line 403 at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.SD.LLBLGen.Pro.ORMSupportClasses.IEntity.SetRelatedEntity(IEntity relatedEntity, String fieldName) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityBase.cs:line 4077 at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.PerformSetRelatedEntity(TEntity entity) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityCollectionBase.cs:line 1430 at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore1.PerformAdd(T item) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Core\CollectionCore.cs:line 1330 at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.Add(T item) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Core\CollectionCore.cs:line 352 at ABS.BusinessObjects.EntityClasses.PartRevisionEntity.SetRelatedEntity(IEntity relatedEntity, String fieldName) in D:\CSD Projects\ABS_Manufacturing\ABS_Manufacturing_Source\ABS.BusinessObjects\EntityClasses\PartRevisionEntity.cs:line 581 at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.SD.LLBLGen.Pro.ORMSupportClasses.IEntity.SetRelatedEntity(IEntity relatedEntity, String fieldName) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityBase.cs:line 4077 at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.SetSingleRelatedEntityNavigator(IEntity toSet, String navigatorNameInRelatedEntity, String navigatorNameInThis, IEntity currentValue, Boolean oppositeNavigatorIsPresent) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityBase.cs:line 3642 at ABS.BusinessObjects.EntityClasses.OrderDetailEntity.set_PartRevision(PartRevisionEntity value) in D:\CSD Projects\ABS_Manufacturing\ABS_Manufacturing_Source\ABS.BusinessObjects\EntityClasses\OrderDetailEntity.cs:line 1689 at ABS.BusinessObjects.EntityClasses.OrderDetailEntity.GetSinglePartRevision(Boolean forceFetch) in D:\CSD Projects\ABS_Manufacturing\ABS_Manufacturing_Source\ABS.BusinessObjects\EntityClasses\OrderDetailEntity.cs:line 853 at ABS.BusinessObjects.EntityClasses.OrderDetailEntity.get_PartRevision() in D:\CSD Projects\ABS_Manufacturing\ABS_Manufacturing_Source\ABS.BusinessObjects\EntityClasses\OrderDetailEntity.cs:line 1680 at ABS.BusinessObjects.EntityClasses.OrderDetailEntity.get_PartRevisionDescription() in D:\CSD Projects\ABS_Manufacturing\ABS_Manufacturing_Source\ABS.BusinessObjects\EntityClasses\OrderDetailEntity.cs:line 1886

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Jun-2011 04:57:11   

How exactly are you binding to the bindingSource? (by code? design view?)

David Elizondo | LLBLGen Support Team
Dusty
User
Posts: 24
Joined: 19-Feb-2008
# Posted on: 27-Jun-2011 03:10:52   

The bindings are all set in the form.designer.cs I don't beleive there are any places outside of the designer code that change the bindings in this example.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Jun-2011 06:10:32   

I can't reproduce it with the latest LLBLGen v3.1 build. See my attached example. Please see if you can reproduce it there.

If you can't reproduce it with my Northwind example, then something is going on in your code. Please see if you can cook a repro project we can use to reproduce the problem. You can open a HelpDesk thread (private) to do that.

David Elizondo | LLBLGen Support Team