Operation is not valid due to the current state of the object

Posted by DBa on Stack Overflow See other posts from Stack Overflow or by DBa
Published on 2010-04-12T15:09:24Z Indexed on 2010/04/12 15:12 UTC
Read the original article Hit count: 326

Filed under:
|
|
|

Sometimes, when running a Mono .NET application (it seems to not depend on the input data, as it does not change), I run into following situation: when trying to Dequeue an element from a (non-empty, I check its Count beforehand) Queue, an exception is thrown:

Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object at System.Collections.Generic.Queue1[DBWorkItem].Peek ()[0x00000] at System.Collections.Generic.Queue1[DBWorkItem].Dequeue () [0x00000] at DBProcessor.process (System.Object q) [0x0006b] in <...>

Though I can certainly catch this exception, the element is dequeued and lost. Has anyone else encountered this behavior, too?

© Stack Overflow or respective owner

Related posts about c#

Related posts about mono