Error getting order - Collection was modified

Discussions related to custom development with Select.
Post Reply
JeremyArmstrong
Posts: 9
Joined: Wed Jul 06, 2011 10:11 am

Error getting order - Collection was modified

Post by JeremyArmstrong »

When the following line of code executes:

using (var order = softProOrderTrackingClient.GetOrder(softProOrderQuerySpec, true))

I am encountering the following error:


Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at SoftPro.BusinessObjects.Base.MutabilityGroupsContainer.GroupsAffectedByInput(String dataItemName)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.OnDataValueChanged(Engine e, List`1 changedItems)
at SoftPro.BusinessObjects.Base.DataChanged.Invoke(Engine engine, List`1 changedItems)
at SoftPro.BusinessObjects.Base.DataValueCache.DispatchQueuedChangeNotifications()
at SoftPro.BusinessObjects.Base.DataValueCache.ReleaseChangeNotifications()
at SoftPro.BusinessObjects.Base.DataValueCache.DispatchQueuedChangeNotifications()
at SoftPro.BusinessObjects.Base.DataValueCache.ReleaseChangeNotifications()
at SoftPro.BusinessObjects.Base.DataValueCache.DispatchQueuedChangeNotifications()
at SoftPro.BusinessObjects.Base.DataValueCache.DispatchChangeNotification(List`1 changedNodes, ContextRoot root)
at SoftPro.BusinessObjects.Base.DataValueCache.ClearAdditionalChargesItems(ContextRoot root)
at SoftPro.BusinessObjects.Base.HUDLineEngine.BusObCache_AddedRemoved(IBusinessObject obj, AddRemoveType addedOrRemoved)
at SoftPro.BusinessObjects.Base.AddRemoveBusinessObjectListener.Invoke(IBusinessObject obj, AddRemoveType addedOrRemoved)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.OnObjectAdded(IBusinessObject obj)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.GetBusinessObject(String contextName, Guid primaryKey, ContextRoot rootContext, Boolean allowDisambiguation, SqlDataReader openReader, Boolean allowLoad, Boolean loadingAsCopy, Boolean acquiringRoot, Guid idForNewObject)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.GetRootObject(String contextName, Guid primaryKey, ContextRoot rootContext, Boolean loadingAsCopy)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.AcquireRootReference(String contextName, Guid primaryKey, Boolean loadAsCopy)
at SoftPro.OrderTracking.Client.OrderTracking.OpenOrderObject(Guid id)
at SoftPro.OrderTracking.Client.OrderTracking.OpenOrder(Guid id, Boolean readOnly, Boolean isTemplate)
at SoftPro.OrderTracking.Client.OrderTracking.GetOrderOrTemplate(OrderQuerySpec spec, Boolean readOnly, Boolean isTemplate)

We had a few open successfully without this error, but we are suddenly running into this. Any ideas why this might be happening?
JeremyArmstrong
Posts: 9
Joined: Wed Jul 06, 2011 10:11 am

Re: Error getting order - Collection was modified

Post by JeremyArmstrong »

This related thread helped answer my question. It is, I believe, because we are being notified on each change, but not necessarily a saved change. In the meantime, another change is made to the order, which causes it to be out of sync. I think we will handle this through better filtering.

viewtopic.php?f=6&t=285
Post Reply