This week, several of our .NET (C#) web applications have been thowing the error “Operation is not valid due to the current state of the object“.
They are all web apps and share the same front-end and database servers although they all query separate databases.
I’ve never seen this error before, so when it appeared in three seemingly unrelated apps I thought something must be up.
My question is not so much as to what the error means, but whether anyone knows of a possible change to the server which could introduce a condition where this is more likely to happen?
I know the front-end server was restarted recently so a config setting could have been changed there but the database server has been up all the time.
Looking at a stack trace, one app mentions ThrowIfMaxHttpCollectionKeysExceeded() but there has been no increase or indeed any change to any of the apps’ code-behind which could trigger such an error.
What could have changed?
Have you applied any security updates lately?
Microsoft recently patched several security holes: Microsoft Security Bulletin MS11-100.
One potential side-effect of the fix is that HTTP submissions with lots of elements — for example, forms with lots of fields — will cause an
InvalidOperationExceptionto be thrown fromThrowIfMaxHttpCollectionKeysExceeded.If your application legitimately needs to submit many elements then you can edit your
web.configto raise the limit: