Index was out of range. Must be non-negative and less than the size of the collection- MS CRM 4.0

Most of the time you will get this error when you will try to retrieve data from Grid View, and it has no rows. But if you have rows in Grid View, make sure you have enabled view state. If you have already enabled view state but you are still getting this error and you have deployed your webapplication under ISV folder in MS CRM 4.0, then here is the issue.

MS CRM web.config file overrides setting of your web application, so you need to specifically change web.config file of MS CRM. You need
to change lines in web.config file like below

<pages buffer=”true” enableSessionState=”true” enableViewState=”true” validateRequest=”false”/>

                                   <sessionState mode=”InProc”/>


Enjoy !!!


Leave a Reply

Your email address will not be published. Required fields are marked *