NHibernate exception counter changed

I have a multi-threaded NHibernate application with ThreadStaticSessionContext. I associate each thread with 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 have no clue ...

+4
source share
1 answer

This exception is usually raised when adding / removing from the collection during its enumeration (for example, in the foreach ).

+1
source

All Articles