Who, what tha..., why? How to set up Opf3 and keep it running smoothly. Search this Forum to find others who have driven down your road and have advice and tips to help you out (btw. we are helping too
).
 | |
| | The following code snippets got a ConcurrencyException at the PersistChanges method. What could I be doing wrong?
Private _collFirstName As ObjectSet(Of OPF3.FirstName) ..... Dim context As ObjectContext = Session.Current.ObjectContext context.ConcurrencyManager = New Md5ConcurrencyManager Dim searcher As ObjectSearcher(Of OPF3.FirstName) = context.GetObjectSearcher(Of OPF3.FirstName)() _collFirstName = searcher.FindAll("ClientID = {0}", Tools.ClientID.ToString) bsFirstName.DataSource = _collFirstName ugrdFirstName.DataSource = bsFirstName
..... Dim clnt As OPF3.FirstName = DirectCast(bsFirstName.Current, OPF3.FirstName) Dim context As ObjectContext = Session.Current.ObjectContext Try Using t As Storages.Transaction = context.StartTransaction() context.PersistChanges(_collFirstName) t.Commit() End Using ..... Chili.Opf3.Concurrency.ConcurrencyException was unhandled Message="A concurrency exception happened: Checksums different." Source="Chili.Opf3" StackTrace: at Chili.Opf3.Concurrency.Md5.Md5ConcurrencyManager.OnBeforeUpdate[T](T obj, ConcurrencyManagerEventArgs e) at Chili.Opf3.ObjectPersister.Update[T](T obj, ObjectInfo objectInfo, PersistDepths persistDepth) at Chili.Opf3.ObjectPersister.PersistChanges[T](T obj, PersistDepths persistDepth) at Chili.Opf3.ObjectContext.PersistChanges[T](T obj, PersistDepths persistDepth) at Chili.Opf3.ObjectSet`1.Persist(ObjectContext context, PersistDepths persistDepth, PersistingTrace persistingTrace) at Chili.Opf3.ObjectSet`1.Chili.Opf3.ICustomPersister.Persist(ObjectContext context, PersistDepths persistDepth, PersistingTrace persistingTrace) at Chili.Opf3.ObjectContext.PersistChanges[T](T obj, PersistDepths persistDepth) at Chili.Opf3.ObjectContext.PersistChanges[T](T obj) at MailHouse2.Forms.ctrlCullNames.FirstNameBindingNavigatorSaveItem_Click(Object sender, EventArgs e) in \\mombasa\Data\My Documents\Larry\Visual Studio 2005\Projects\MailHouse2\MailHouse2.Forms\ctrlCullNames.vb:line 187
|
 | |
| | The concurrency manager's goal is: It checks whether another has changed the object in the database, while you had it in memory. This is done, because otherwise your changes are going to overwrite the changes of the thirth person, withouth having you known that somebody else did changes. Means you could overwrite the changes of somebody else without having seen that the other person has changed.
Now the Md5ConcurrencyManager does it by creating checksums. Each time an object is loaded an MD5 is constructed on it. When you update the object (PersistChanges) the concurrency manager does a re-load of the current object (as separate instance) and calculates the checksum (MD5) for that. Now the checksum of your object (the one that is going to be persisted), that has been created during load, is compared to the checksum of the reloaded object. If these don't match the concurrency manager takes this as: somebody changed the object in the storage in the meantime.
Form your code (the one that you pasted) everything seems ok, but perhaps you did another load of the same object in the meantime and had it persisted in the mean time by another thread or another instance of the application?
Regards, Christian Liensberger
|
 | |
| | Christian,
The object load is done in the form load event. It is a very simple program.
I am using a BindingSource, a BindingNavigator and an Infragistics win grid. After initial load, there are 7020 objects in the collection. When I stopped the program at the BindingNavigator AddNewItem event, there were still 7020 objects in the collection and an open row in the grid for me to add a new object.
When I entered the BindingNavigator SaveItem event, there were 7021 objects in the collection. This event is where I tried to persist the changes and got the error message.
Any suggestions for me to try?
Thanks, Larry
|
 | |
| | This is strange... How did that object came to the list?
|
 | |
| | Christian,
When you drag an object from the DataSources window to the designer surface containing a form, it automatically creates a BindingSource and a BindingNavigator (a bunch of ToolStrip objects). The BindingNavigator's BindingSource property is automatically set to the BindingSource. Additionally, it creates a DataViewGrid, which I deleted and replaced with an Infragistic's grid.
One of the buttons on the BindingNavigator is the +, the Add New button. Clicking on this button at runtime automatically calls the AddNew method on the associated BindingSource object.
|
 | |
| | OK!
Are you sure that nobody else changed the object in the database in the meantime? This error is only seen if somebody changed the object while being in memory.
Christian
|
 | |
| | Yes, I am sure. If something is changing, it's beyond me.
|
 | |
| | Larry Marshall wrote: Yes, I am sure. If something is changing, it's beyond me. Are you formatting the inserted data in the database? Removing digits or so?
|
 | |
| | No
|
 | |
| | Please send me an e-mail to our support handle. I'll send you our internal release... We have enhanced the MD5 checksum code...
Regards, Christian Liensberger
|
 | |
| | Christian,
I put together a sample for you. In doing so, I changed all controls to MS removing all Infragistics. The error disappeared. So it is somehow related to the UltraGrid.
|
 | |
| | Larry Marshall wrote: Christian,
I put together a sample for you. In doing so, I changed all controls to MS removing all Infragistics. The error disappeared. So it is somehow related to the UltraGrid. Are you having circular references in your persistents? Persistent1 -> Persistent2 -> Persistent2?
Christian
|
 | |
| | No, I don't think so.
|