Pages

Wednesday, February 20, 2013

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

I have discovered how to fix this, but there was not a whole lot of information out there yet, so I thought I would add a post with all the information I found. Hopefully you can add to the discussion with anything useful to add.

Solution

Before getting into the details, the quick solution is to add key="aspnet:MaxHttpCollectionKeys" value="?" to the appSettings in Web.config. The default value is 1000, which appears to have changed in a recent security update. Set the value to something higher than 1000, but understand the security implications before doing this. There is a reason why Microsoft made the change. I recommend reading the KBs mentioned in this post.

Here is the key I added to <appSettings> in Web.config for Reporting Services. On the Report Server Web.config you may have to add <appSettings>.

<add key="aspnet:MaxHttpCollectionKeys" value="1500" />


Symptoms

After adding several security updates from Microsoft Update on one of our Reporting Services instances, we started receiving complaints that some reports would not run and would display the following message.
Operation is not valid due to the current state of the object
Our Symptoms
  • Reports with large number of parameters, or form fields, would not return the report and display “Operation is not valid due to the current state of the object” in Reporting Services and Report Server.
  • Applications that called the Report Server for a report with a large number of parameters, or form fields, would display a generic “rsInternalError” message.
  • We installed Security Update for Microsoft .NET Framework 4 on XP, Server 2003, Vista, Windows 7, Server 2008 x86 (KB2656351). http://support.microsoft.com/kb/2656351
  • Event ID 1309 in the Application Event Viewer from source ASP.NET with: Event code: 3005, Event message: An unhandled exception has occurred.

Others’ Symptoms
  • Source Error: System.InvalidOperationException
  • Stack Trace: InvalidOperationException: Operation is not valid due to the current state of the object.

Cause

This appears to be caused from Microsofts security bulletin MS11-100 (http://technet.microsoft.com/en-us/security/bulletin/ms11-100) for the .Net framework. In short, the update resolves vulnerabilities in how .Net handles requests, authenticates users, and cached content.

It looks like this has impacted ASP.Net environments that have installed KB 2656351. Any of these security updates described in security bulletin MS11-100 may also cause this issue, although I have only researched 2656351.

  • KB 2656351
  • KB 2656356
  • KB 2657424
  • KB 2656352
  • KB 2656362
  • KB 2656355
  • KB 2656358
  • KB 2656353

Here are some links I used to bring this information together.


Hope this helps. Any contribution is appreciated.

Regards,
Jon

5 comments:

  1. Useful information. Thank you.

    ReplyDelete
  2. Adding the key helped us. Thank you.

    ReplyDelete
  3. That helped after searching all day. I appreciate it.

    ReplyDelete
  4. Hi, whereabouts in the web.config file do I put it? Thanks.

    ReplyDelete

All comments will be moderated to ensure clean and relevant content.