Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate exception enumerator was modified

Tags:

c#

nhibernate

I have a multithreaded NHibernate application with ThreadStaticSessionContext. I bind un each thread a new session. Before exiting the thread I commit the transaction and i get

enumerator was modified

  at NHibernate.Util.SequencedHashMap.OrderedEnumerator.MoveNext()  
  at NHibernate.Util.IdentityMap.get_EntryList()  
  at NHibernate.Util.IdentityMap.ConcurrentEntries(IDictionary map)  
  at NHibernate.Event.Default.AbstractFlushingEventListener.PrepareEntityFlushes(IEventSource session)  
  at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent event)  
  at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)  
  at NHibernate.Impl.SessionImpl.Flush()  
  at NHibernate.Transaction.AdoTransaction.Commit()  
  at ...

I don't have a clue...

like image 558
DaeMoohn Avatar asked Nov 15 '22 13:11

DaeMoohn


1 Answers

This exception is usually thrown when you add/remove from a collection while it is being enumerated (like in a foreach statement).

like image 62
Richard Szalay Avatar answered Dec 17 '22 23:12

Richard Szalay