SharePoint 2010 value is not in expected range

Everything was fine on the development server, but after deployment, there is an ArgumentException: Value does not fall within the expected range. Unfortunately, there is no way to directly debug the damaged web part, so I only have some log information (for example, the exception message above and the code section shown below). Here is the code throwing the exception:

 using (SPSite site = new SPSite("http://mysite")) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists.TryGetList("MySPList"); foreach (SPListItem item in list.Items) { if (item["Code"].ToString() == code) { if (item["Favorites"] != null) { if (item["Favorites"].ToString().Contains(web.CurrentUser.ID + ";#" + web.CurrentUser.Name)) { // first case simple code } else { // second case simple code } } else { // second case simple code } break; } } } } 
+4
source share
1 answer

The problem was the View Viewup Threshold parameter:

  • Log in to Central Administration .
  • In the Application Management section , click Manage Web Applications .
  • Select your desired web application.
  • In the ribbon above, click General Settings and select Destruction of resources from the drop-down menu.
  • Find the Threshold List Lookup Threshold and change its value (from 8 to 10 in my case).
+6
source

Source: https://habr.com/ru/post/1493596/


All Articles