Sunday, October 4, 2009

NHibernate error ‘Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index’

I got the following NHibernate error when I tried to commit an entity class using a transaction:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
I figured out that two fields in the .hbm.xml mapping file reference the same column in a table. Simple bug, but complicated to debug.

8 comments:

  1. thanks mate, quick and to the point

    ReplyDelete
  2. Thanks a million! Just ran into this issue and fear that it would have taken me a LONG time to figure out the cause had I not ran across you blog! Great stuff!

    ReplyDelete
  3. Thanks, that was really it.

    ReplyDelete
  4. Thank you very much stuck with that error was 3 days ago

    ReplyDelete
  5. Inacredibilível!!!

    Passei raiva com isso uma semana.
    Very much thanks!!!!

    ReplyDelete
  6. You saved me from a day of agony and pain.
    Thank you very much!!!
    Keep up the good work

    ReplyDelete
  7. It's help me to solve.

    ReplyDelete