Collection was modified; enumeration operation may not execute.

Collection was modified; enumeration operation may not execute.

Old forum URL: forums.lhotka.net/forums/t/4606.aspx


JTWebMan posted on Wednesday, April 02, 2008

I am getting this error intermittently and I am woundering if anyone else has seen it before. It seems like its in the Csla.Validation.ValidationRules.CheckRules(List`1 list) method but I bought its a CSLA error. Did I implement something wrong? I can send code if need be. We are running version 2.1.0.

Here is the stack trace on the error:
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Csla.DataPortalException: DataPortal.Fetch failed (System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.List`1.Enumerator.MoveNext() at Csla.Validation.ValidationRules.CheckRules(List`1 list) at Csla.Validation.ValidationRules.CheckRules() at ASH2.Data.Benefits.Group.ExecuteFetch(Criteria criteria, SqlConnection cn) in C:\projects\Namespaces\ASH2.Data.Benefits\Generated\Group.vb:line 583 at ASH2.Data.Benefits.Group.OnFetch(Object criteria) in C:\projects\Namespaces\ASH2.Data.Benefits\Generated\Group.vb:line 567 at ASH2.Data.Benefits.Group.DataPortal_Fetch(Object criteria) in C:\projects\Namespaces\ASH2.Data.Benefits\PartialClasses\Group.vb:line 23) ---> Csla.Server.CallMethodException: DataPortal_Fetch method call failed ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.List`1.Enumerator.MoveNext() at Csla.Validation.ValidationRules.CheckRules(List`1 list) at Csla.Validation.ValidationRules.CheckRules() at ASH2.Data.Benefits.Group.ExecuteFetch(Criteria criteria, SqlConnection cn) in C:\projects\Namespaces\ASH2.Data.Benefits\Generated\Group.vb:line 583 at ASH2.Data.Benefits.Group.OnFetch(Object criteria) in C:\projects\Namespaces\ASH2.Data.Benefits\Generated\Group.vb:line 567 at ASH2.Data.Benefits.Group.DataPortal_Fetch(Object criteria) in C:\projects\Namespaces\ASH2.Data.Benefits\PartialClasses\Group.vb:line 23

JTWebMan replied on Monday, April 07, 2008

This issue was fixed in version 3.0.4.

JT

Copyright (c) Marimer LLC