Collection was modified; enumeration operation may not execute error

Collection was modified; enumeration operation may not execute error

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


jordans@magenic.com posted on Tuesday, August 18, 2009

I recently upgraded from Silverlight 2 to Silverlight 3 for a project using CSLA 3.6. I'm getting a error when it tries to add the item to the list. I found a similiar issue and thought they might be related.
http://forums.lhotka.net/forums/post/35318.aspx
Is there a fix for this?

protected override void AddNewCore()
{
if (!AuthorizationRules.CanCreateObject(typeof(OrderQuestionnairePerson)))
throw new SecurityException("You do not have right to create new person.");
OrderQuestionnairePerson newOrderQuestionnairePerson = OrderQuestionnairePerson.NewOrderQuestionnairePerson();
newOrderQuestionnairePerson.PersonTypeID = this.ParentOrder.DefaultPersonTypeID;
// ERROR HAPPENS HERE on the Add
Add(newOrderQuestionnairePerson);
OnAddedNew(newOrderQuestionnairePerson);
ParentOrder.UpdateQuantity();
}

This is how it is being called.
private void btnAdd_Click(object sender, RoutedEventArgs e)
{ CurrentOrder.QuestionnairePersons.AddedNew += (o1, e1) =>
{
QuestionnairePersonsList.ScrollIntoView(e1.NewObject, QuestionnairePersonsList.Columns[0]);
};
CurrentOrder.QuestionnairePersons.AddNew();
}

RockfordLhotka replied on Monday, August 24, 2009

There's a fix for a similar (or the same?) issue in 3.7 or 3.7.1.

CSLA 3.6 isn't supported with SL3 - I had to tweak a couple things to make SL3 really work and that was done in 3.7.

This could be yet another issue however, so if you still see the problem with 3.7 let me know.

Copyright (c) Marimer LLC