StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
OK, it looks like setting a value on the row is causing the DefaultView to raise a ListChanged event, which is being nested into the middle of the check for whether the record exists in the dictionary and adding the record to the dictionary. We can pause the changed events by using wrapping the call to NewRow() with bo.PauseChangedEvents() and bo.ResumeChangedEvents(). Give that a try and see how that works.
|
|
|
jsantos
|
|
Group: StrataFrame Users
Posts: 26,
Visits: 87
|
I thought I would do one better and provide the 2 call stacks in one Excel file. I didn't want to exclude anything that may be helpful.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Yeah, that double call is what's causing the error. Will you send me a screenshot of the Call Stack window on each of those 2 times that it hits the line to Me._BusinessObjectList.Add()? That should give us a clue as to why it's hitting it twice.
|
|
|
jsantos
|
|
Group: StrataFrame Users
Posts: 26,
Visits: 87
|
Hi Ben, Thanks for the information. So I put a break point on Me._BusinessObjectList.Add(index, loReturn) and it gets hit once prior to error for the same child business object. So it goes into CreateShareAndAddBusinessObject 2 times on one call to .NewRow. The first time through no error.
I checked the SharedDataTableKey and from what I can tell the parent and child do not share the same key.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
By the way, calling .Add() calls .NewRow() internally. Calling .Add() just also goes through the logic of enabling the bound controls through the editing state. NewRow() doesn't mess with any of the UI stuff, so that's why it's usually recommended for programmatically adding rows.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Howdy J, The CreateShareAndAddBusinessObject() method is called from within the Get of the Item() property on BusinessBindingSource. In the Get, it calls Not _BusinessObjectList.TryGetValue(index, loReturn), which effectively tests whether the key is contained in the dictionary and returns the value. So, if the Me.CreateShareAndAddBusinessObject(index) is being called, then the specified index does not exist within the dictionary. So, since the index isn't in the dictionary when CreateShareAndAddBusinessObject() is called, then something within CreateShareAndAddBusinessObject() is adding a record to the dictionary before the call to add the record to the dictionary. There are 4 operations, you'll need to check into: 1) your BO's constructor 2) some logic happening when the current data table is shared 3) setting the parent relationship, and 4) setting the parent business object. Something in there is adding to the dictionary before the code to add to the dictionary. Try putting a breakpoint on the line for Me._BusinessObjectList.Add(index, loReturn) and see if something hits that before you're expecting it to. Also, do you have 2 business objects trying to use the same shared data table? Through the SharedDataTableKey perhaps?
|
|
|
jsantos
|
|
Group: StrataFrame Users
Posts: 26,
Visits: 87
|
I have also just tried using .Add and I get the same error in the same location CreateShareAndAddBusinessObject.
|
|
|
jsantos
|
|
Group: StrataFrame Users
Posts: 26,
Visits: 87
|
I have attached a screenshot of the code that I think you will see where it is happening. Thanks for your help.
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Hi, Thanks for the image and yes, NewRow() is recommended for adding rows programmatically. Still, can you please explain in a wider scope what you are trying to do? also it will help if you can post the code Sub or Function where you are trying to add the new record? I use BBS with DevExpress all the time and have notice that when showing records in the DevEx grid using the BBS, and using the same source BO to modify the record, all kind of error show up. My solution is to use 2 BO, one for the BBS to show in read only grid and one for make the changes. I know this logic will require more code to keep the grid in synch with updates to 2nd BO, but that have worked for me all the time.
Edhy Rijo
|
|
|
jsantos
|
|
Group: StrataFrame Users
Posts: 26,
Visits: 87
|
Sorry about the image. Added attachment We are adding a new row programatically. As I understand .NewRow is recommended for programatically adding new rows.
|
|
|