Monday, February 02, 2009

System.IndexOutOfRangeException On LoadControlState Event

Today we came across some sudden errors in our web-based apps.

System.IndexOutOfRangeException (Index was outside the bounds of the array)

with a stack trace of:

at System.Web.UI.WebControls.GridView.LoadControlState(Object savedState) at System.Web.UI.Control.LoadControlStateInternal(Object savedStateObj) at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The stack trace makes it appear to be server-related rather than application-related. That indeed turned out to be the case.

Cause - some of the servers in the web farm had a .Net service pack update, and the other ones didn't.
The viewstate was getting all wrapped around the axle when going from an updated server to a non-updated one, and/or vice-versa.

Solution - Ensured all servers in the farm had the same .Net framework service pack.
If you're seeing this error (with a similar stack trace) chances are your server cluster suffers from the same problem.


Brett said...

Thank you so much for this post! Our clients kept having these inexplicable out of range errors and we could not figure out the cause, but then I stumbled across your post and we made the service pack deployments the same across all of the servers in our cluster. Problem solved!

Post a Comment