PreDeleteEventListener and InvalidOperationException
12 views
Skip to first unread message
NiHique
unread,
Apr 1, 2009, 11:16:57 AM4/1/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nhusers
Hi,
I am using NH 2.1 and custom PreDeleteEventListener (code below).
Listener works, deletes entity, but when I flush session I get this
error
*** Failures ***
System.InvalidOperationException: 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 NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions
(IEventSource session)
at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush
(FlushEvent event)
at NHibernate.Impl.SessionImpl.Flush()
Code for listener is
public class TaskPaneCleanerEventListener :
IPreDeleteEventListener
{
public bool OnPreDelete(PreDeleteEvent e)
{
var taskPaneSource = e.Entity as ITaskPaneSource;
var taskPaneTarget = e.Entity as ITaskPaneTarget;