I have a Dev and a Production SharePoint 2016 environment. For CRUD with lists I am using LINQ to SharePoint (SPMetal) generated classes. I have a list where 27 columns are Person Type. In my dev(http://sp2016/) environment the list is in root/main site but in Prod it is in subsite (https://sp2016/leaveauto). In both environment I have increased the Resource throttling value from 8 to 50 for Lookup View field. From the list I am taking a Person's Id value (column name: HOD) from a specific Person type column with below code

using (MyDataContext objDataContext = new MyDataContext(_webUrl))
                            int approverId = objDataContext.ApproverInfo.FirstOrDefault(x => (string.Compare(x.DeptID,deptId)==0) && (string.Compare(x.Location, location)==0)).HODId;
                        catch (Exception ex)

here, HODId is LINQ to SharePoint generated column for HOD and deptId & location values I am passing with parameter.

In Dev environment it is working fine, but in Prod it is giving below error

{System.ArgumentException: Value does not fall within the expected range.
   at Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName, Boolean bThrow)
   at Microsoft.SharePoint.SPListItemCollection.GetColumnNumber(String groupName, Boolean bThrowException)
   at Microsoft.SharePoint.SPListItem.GetValue(SPField fld, Int32 columnNumber, Boolean bRaw, Boolean bThrowException)
   at Microsoft.SharePoint.SPListItem.get_Item(String fieldName)
   at Microsoft.SharePoint.Linq.PropertyMap.GetSPFieldValue(PropertyMap pm, SPListItem item, JoinPath joinPath)
   at Microsoft.SharePoint.Linq.SPItemMappingInfo.MaterializeEntity[TEntity](DataContext dc, SPDataList list, SPListItem item, SPItemMappingInfo itemMappingInfo, JoinPath joinPath)
   at lambda_method(Closure , SPListItem )
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.SharePoint.Linq.SPLinqProvider.Execute[T](Expression expression)
   at ShopSignboard.lib.Utility.FindNonFinancialApprover(String approvalStatus, String deptId, String location)}

How can I solve this problem?

1 Answer 1


A couple of possibilities:

Is your project building as 32 bit or 64 bit? Odd errors are reported if targeting 32 bit.

Are you using the "internal" names of the columns? For example, was Title column renamed to DeptId? "Title" is still the internal name.

  • I am building the project as "Any CPU", I have checked the internal name also and it is same. Oct 17, 2019 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.