Suddenly I am getting this error «Value does not fall within the expected range» whenever I try to add a reference to any project. This also happens with a new blank project. It can list the current references fine.
I rebooted the computer. I am not sure if the recent Update 2 caused this. This is my first add reference since the update. I am using Visual Studio 2013 on Windows 7 64bit.
Any ideas?

![]()
Aristos
65.5k16 gold badges117 silver badges150 bronze badges
asked May 28, 2014 at 1:32
Tony_HenrichTony_Henrich
41.4k72 gold badges229 silver badges369 bronze badges
1
I did a ‘devenv /setup’ and that fixed it.
Detail
- Exit Visual Studio
- Click
Start - Type
cmd, right clickCommand Promptand selectRun as administrator -
Navigate to the appropriate Visual Studio folder
VS2012:pushd %programfiles(x86)%Microsoft Visual Studio 12.0Common7IDE
VS2015:pushd %programfiles(x86)%Microsoft Visual Studio 14.0Common7IDE
VS2017:pushd %programfiles(x86)%Microsoft Visual Studio2017<Edition>Common7IDE
VS2019:pushd %programfiles(x86)%Microsoft Visual Studio2019<Edition>Common7IDE -
Type
devenv /setupand press enter - When the command prompt returns, you’re done. Close the command window, reopen Visual Studio, and test to see if the error’s resolved.
More Information
https://msdn.microsoft.com/en-us/library/ex6a2fad.aspx
answered May 28, 2014 at 1:40
Tony_HenrichTony_Henrich
41.4k72 gold badges229 silver badges369 bronze badges
14
In my case deleting .suo file in .vs[solutionName] folder fixed the problem in Visual Studio 2022
answered Aug 9, 2022 at 5:43
![]()
Elvin MammadovElvin Mammadov
23.7k10 gold badges39 silver badges81 bronze badges
5
In my case, project was set to use local IIS (when the project set up to use local IIS but the app does not deployed there, it cannot load project but states clearly in the error message. However this time I was keep getting Value does not fall within the expected range with any other info.
Only «solution» worked for me was:
- Edit csproj file
- Set
<UseIISExpress>totrue - Set
<UseIIS>tofalse - Then reload the project.
(after that you can set your local IIS again)
answered Feb 21, 2020 at 14:31
![]()
0
Some projects (e.g. some web services) require that Visual Studio be run as an administrator. After a Visual Studio upgrade, I hadn’t noticed that it was no longer being started with elevated privileges automatically. When I corrected this, all the projects in the solution loaded.
answered Oct 10, 2019 at 11:21
![]()
Graham LaightGraham Laight
4,5803 gold badges29 silver badges28 bronze badges
1
I have tried to delete the .vs hidden folder placed in the same solution directly and it works for me try this it’s straightforward to fix this issue.
thanks.
answered Aug 26, 2022 at 6:46
3
In my case, this was because I needed a specific version of the .NET Core SDK installed.
Once I got it downloaded and installed, the projects loaded fine. Unfortunately there was no additional information in the Output tab hinting at this.
answered Oct 9, 2019 at 21:39
emraginsemragins
4,3512 gold badges33 silver badges48 bronze badges
1
In my case the file name inside the Solution .sln was wrong (not exist on disk).
I open the solution file MyFullsolution.sln using a text editor and check the Project load files and found that the project ProjectFile.csproj that fails to load was typed wrong.
How that happens ? Because I rename it from the solution some day, but I use the same ProjectFile.csproj again on a different solution! and I rename it in one solution, but the other just didn’t know it… and get the same message (that actual not help at all).
So was my mistake the file rename from the other solution.
answered Sep 20, 2020 at 19:49
![]()
AristosAristos
65.5k16 gold badges117 silver badges150 bronze badges
In my case it was simple, if the file is open and then I run it, it will run. If the file is closed and then I run it by right clicking from the «Solution Explorer», then it throws the error you mentioned.
So, simple steps:
In the Solution Explorer,
- Double click on the file and open it
- Right click on the file and select «Start with Debugging» or «Start without Debugging»
answered Jul 18, 2019 at 13:59
calvincalvin
1531 silver badge9 bronze badges
I also got the same error with «web» tab missing from project properties, for those having this issue can try changing the target framework of the project.When I changed target framework from 4.6.2 to 4.7.2, the web tab appeared again.
answered Aug 19, 2019 at 5:08
![]()
I have seen this box in VS-2019 16.5.4 in a Winforms/4.8 app with Std classlibs, on attempting to close one of the Winforms/4.8 source file tabs. The message came up, the tab refused to close.
Solved it by closing an re-opening the Solution.
answered Jun 15, 2020 at 12:03
GoodiesGoodies
1,87121 silver badges25 bronze badges
I just had the same, it was only one file which casing this issue, When I read the solution above I was worried to fix all visual studio because one .cs file so I tried to right click on the (TAB header) beside the (X) button which closes this and click on (Close All documents)…
it worked : )
answered Jun 25, 2020 at 11:06
![]()
Khaleel HmozKhaleel Hmoz
9592 gold badges13 silver badges24 bronze badges
Kind of a dumb oversight on my part.. but depending on the action that had caused it, you may want to check your console output as well. In my case it was a project that would not load. While there were no explicit errors, the consol window indicated that a file was missing based on a directive from the csproj.
ECommerceProdEcommerceUtilityECommerceCommandsECommerceCommands.csproj
: error : The imported project «C:Program Files
(x86)MSBuildExtensionPack4.0MSBuild.ExtensionPack.tasks» was not
found.Confirm that the expression in the Import declaration «C:Program
Files (x86)MSBuildExtensionPack4.0MSBuild.ExtensionPack.tasks» is
correct, and that the file exists on disk.
answered Feb 23, 2021 at 17:05
Bonez024Bonez024
1,3301 gold badge13 silver badges21 bronze badges
I tried the solution described by Tony_Henrich, as it seemed helpful.
However in my case, I’m building off a USB drive which is encrypted with BitLocker.
I find that the *.c module I want to look at throws this error if I try to force open it with the C++ editor in VS2019 (I’m updating to 16.10.2, so whatever was just before that rev).
Visual Studio was not opening a *.c module in the editor but popping it up in Notepad. If I FORCED it to use Visual Studio C++ editor I got the «Value does not fall» message.
The file is part of a build tree in a repo I’m not responsible for, and it’s not building, so at the moment I suspect Bitlocker/USB disk corruption is somehow giving Visual Studio some fits.
Tortoise-GIT Blame tool shows different/valid source code and Notepad shows a chunk missing.
My fix was to delete the file from the workspace and try seeing if GIT could restore a valid copy from the repository, and this worked. Now clicking on the *.c module in Windows Explorer and requesting to open it, no longer brings up Notepad, the file opens in Visual Studio.
answered Jun 21, 2021 at 15:38
![]()
Ross YoungbloodRoss Youngblood
4621 gold badge3 silver badges15 bronze badges
Setting up the dev environment for an existing project on a new server: Windows Server 2022, Visual Studio 2022, IPv6 enabled, IIS6 compatibility features installed, public IP address, domain name, web server certificate. The web application does not load. Creating the web application by hand in IIS Manager doesn’t help.
Message box:
Value does not fall within the expected range
Output from: Solution:
error: The Web Application Project webapp is configured to
use IIS. The Web server ‘http://localhost/webapp’ could not be found.
The webapp.csproj file contains:
<IISUrl>http://localhost/webapp</IISUrl>
The project loaded after changing the protocol and the name of the server to match the certificate:
<IISUrl>https://my.domain.com/webapp</IISUrl>
answered Mar 22, 2022 at 2:39
Tom AndraszekTom Andraszek
1,6761 gold badge22 silver badges29 bronze badges
- Remove From My Forums
-
Question
-
i get the error while fetching few fields from list.
it only occurs with 1 field which is a lookup from another list.
i have many more fields which are lookups from other tables, but they donot throw error.
any idea why the error is comming? i have checked the list name, field name and everything is proper.
is it related with permissions, because for certain group of users it works without throwing this error.
Value does not fall within the expected range.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.ArgumentException: Value does not fall within the expected range.
Answers
-
You say have other lookupvalues. How many lookupvalues are you having in your operation?
The List View Lookup Threshold specify the maximum number of Lookup, Person/Group or Workflow status fields that a database query can involve at one time. The list view lookup threshold is default set to 8. Admin users are not restricted by this threshold.
I think this is your problem.You can change this CA -> Web Application Management -> mark your web application -> General Settings -> Resource Throttling.
Please let me know if this works
-
Marked as answer by
Saturday, August 6, 2011 6:06 AM
-
Marked as answer by
-
You are getting a build error because you do not have a reference to the System.Linq namespace.
I think the problem is caused by throttling. You are not allowed to invlove more than default 8 lookups in a query. This rule do not apply if you execute the query as an admin (app.pool account). I assmue your employee list contains more than 8 lookup values.
You could restrict the returned field by setting SPQuery.ViewFields.You are welcome. I am glad it now works.
-
Marked as answer by
Nachiket Kamat
Friday, June 10, 2011 12:05 PM
-
Marked as answer by
IIS applications run on application pools. Application pools receive requests and process them based on the settings defined. One of the settings is application pool identity. This is the account that runs application pool and perform required tasks. You may come across to this error message while trying to set a custom account as application pool identity: “Value does not fall within the expected range.“
This error occurs only if you are specifying a custom account and not using any predefined accounts such as ApplicationPoolIdentity or NetworkService.
The exact error message:
There was an error while performing this operation. Details: Value does not fall within the expected range.

The username and password fields of the custom application pool identity window in IIS Manager has only basic validations such as empty field check, password match check, local user check (no check for domain users). Therefore, “Value does not fall within the expected range” issue is not always a good clue to lead to the solution.
It is likely that there is something simple but easy to miss (a formatting issue in the config files etc.) is causing this issue. I would recommend taking the actions below first:
- Check the application pool identities in the
applicationHost.configfile (C:WindowsSystem32inetsrvConfig) for any syntax issues - Try to obtain a clean copy of
applicationHost.configand replace it with the current one - Restart Windows Process Activation Service (Reference)
- Close and reopen IIS Manager
net stop was /y
net start w3svc
If this doesn’t work:
- Create a new application pool and try set its application pool identity
- Try to open IIS Manager as a local or domain administrator if you are not already
- Check Event Viewer for more details of the error message
If you see Event ID 5021, 5057 or 5059, check out this post for possible solutions: HTTP 503 Service Unavailable (Application pool has been disabled)
This evening, we kept receiving the Error «Value does not fall within the expected range» when trying to configure a custom identify for an IIS Application Pool. In this case, it was IIS 8 on Server 2012 R2 but we’ve also seen issues posted for Version 7.
For those who don’t want or have time to follow my journey, head on down to the end to «The Answer».
We knew the issue wasn’t something we entered: a bad credential rendered an error, and a bad username did the same. So at runtime, everything was great. It was something to do with trying to save the setting.
Event logs, ho!
To figure out how to resolve this, we went into the event viewer. There was nothing in the Application log, so we headed down to Applications and Services Logs => Microsoft => Windows => IIS-Configuration. The logs in here are disabled by default, so they have
to be enabled. (To do so, right-click the log, and choose Enable Log.) Once enabled, re-run the attempt to set the identity, and refresh the view (Actions pane or F5), and now we have some more information on the error. In the results were two Errors (event
ID 42 and 43).
ID 42: Failed to initialize the ‘IISWASOnlyAesProvider’ encryption provider in ‘\?C:windowssystem32inetsrvconfigapplicationHost.config’. Please check your configuration.
ID 43: Failed to encrypt attribute ‘Microsoft.ApplicationHost.AesProtectedConfigurationProvider’.
Now we know the issue identified with ID 42 was the cause of the issue identified in 43. The IISWASOnlyAesProvider encryption provider’s inability to load was the root cause of the inability to encrypt. Since it mentioned the
applicationHost.config file, let’s take a look at it.
We tried renaming [Note: Rename, not delete] the config file, and restarting IIS, but that didn’t work:
C:>net stop was /y
The following services are dependent on the Windows Process Activation Service s
ervice.
Stopping the Windows Process Activation Service service will also stop these ser
vices.
World Wide Web Publishing Service
The World Wide Web Publishing Service service is stopping.
The World Wide Web Publishing Service service was stopped successfully.
The Windows Process Activation Service service is stopping.
The Windows Process Activation Service service was stopped successfully.
C:>net start w3svc
System error
1068 has occurred.
The dependency service or group failed to start.
The Answer
Luckily, we were able to obtain a clean configuration file. We replace the applicationHost.config file (C:windowssystem32inetsrvconfigapplicationHost.config), and restarted services again:
net stop was /y
net start w3svc
After that, we were able to successfully make the changes.
We have tried to find the offending setting, but so far have not had any luck. Hopefully knowing that you can swap out the applicationHost.config file will help you out.
Lessons Learned
- Always keep a clean copy of this file on hand
- Ensure the file is always backed up
I am getting similar error, maybe this stacktrace is of help.
ArgumentException
在 Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller.MoveFocus(COREWEBVIEW2_MOVE_FOCUS_REASON reason)
在 Microsoft.Web.WebView2.Core.CoreWebView2Controller.MoveFocus(CoreWebView2MoveFocusReason reason)
在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
在 System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
在 System.Windows.Input.InputManager.ProcessStagingArea()
在 System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
在 System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
在 System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
在 System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
在 System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
在 System.Windows.UIElement.Focus()
在 System.Windows.FrameworkElement.OnPreviewGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
在 System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
在 System.Windows.Input.InputManager.ProcessStagingArea()
在 System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
在 System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
在 System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
在 System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
在 System.Windows.Interop.HwndKeyboardInputProvider.OnSetFocus(IntPtr hwnd)
在 System.Windows.Interop.HwndKeyboardInputProvider.FilterMessage(IntPtr hwnd, WindowMessage message, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Problem: SharePoint site gave “System.ArgumentException: Value does not fall within the expected range” error!
Here are some possible root causes and solutions:
Case 1: While fetching List item Lookup values programmatically
Root cause: List view threshold value exceeded! This occurs due to the throttling limit on the list view lookup threshold value under web application settings. Try increasing it.
- Go to Central Administration >> Application Management >> Manage web applications
- Select your web application, click on General Settings >> Resource Throttling from the ribbon
- Enter the value for List View Lookup Threshold. E.g. 36
PowerShell script to increase list view lookup threshold value.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $WebApp = Get-SPWebApplication "https://sharepoint.crescent.com/" #Set List View Lookup Threshold $WebApp.MaxQueryLookupFields = 36 $WebApp.Update()
Case 2: Invalid Field Names
When fetching fields, use internal field names or check whether the particular field exists before getting its value. E.g., use item.Fields.ContainsField(“Title”) before fetching or updating a specific field. So, if you got this error after activating a feature or deploying a solution, the culprit is your recent feature/solution!
Case 3: During Check-In under SharePoint Document Library
Got this error while checking in a document? Well, the solution is simple – Do not set the required field property to true on your content types!
Salaudeen Rajack
Salaudeen Rajack — SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!
ОБНОВЛЕНИЕ: Оставил анонимный плакат большой комментарий о внутренних имен. Будьте уверены прочитать его.
При работе с приемниками событий и другой код, ссылающийся на элементы списка SharePoint через объектную модель, Я часто делают ошибки, которые создают эту ошибку во время выполнения:
Ошибка при загрузке и запуске приемника событий Conchango.xyzzyEventReceiver в xyzzy, Версия = 1.0.0.0, Культура = нейтральных, PublicKeyToken = 0dc50a750396c3ac. Дополнительная информация приведена ниже. : Значение не попадает в ожидаемый диапазон.
Я думаю, что это довольно общая ошибка, которая потенциально вызывается множество различных способов. Однако, один простое объяснение в том, что я неправильно ссылки поля. Если имя поля «Срок», Я должен ссылаться на него как это в приемник событий:
Свойства.ListItem[«Срок»]
Когда я неправильно или использовать неверный регистр при ссылке на поле, SharePoint генерирует выше упомянутые ошибки во время выполнения. Например, Это неправильно:
Свойства.ListItem[«Срок»]
</конец>
Подписаться на мой блог.
I am getting the error on the following line for a timer job:
if (listItem["Department"] != null)
Normally this error indicates that it cannot find the field, but there are no spaces and the field label name and strong name are the same. Furthermore, if I write it like this:
if (listItem.Fields["Department"] != null)
I no longer get the error.
The problem is I am trying to call TaxonomyFieldValueCollection on the object and cannot call it by Fields. Is there some nuanced difference between the two that I’m missing that’s causing this error?
EDIT: I figured out the problem. I had set
query.ViewFieldsOnly = true;
and «Department» was a new field and was not set in the ViewFields, so as far as the timer job could tell the field didn’t exist. I simply needed to add the field into the list of fields in ViewField.
asked Jan 28, 2013 at 16:43
user11457user11457
5012 gold badges5 silver badges17 bronze badges
2
I figured out the problem. I had set query.ViewFieldsOnly = true; and «Department» was a new field and was not set in the ViewFields, so as far as the timer job could tell the field didn’t exist. I simply needed to add the field into the list of fields in ViewField.
answered Feb 12, 2013 at 18:58
user11457user11457
5012 gold badges5 silver badges17 bronze badges
1
The first line checks if the value of the data in the column «Department» is null for that specific list item.
The second line checks if the SPField object «Department» is null.
If the SPField exists on the list, it should never be null, but the data stored in that field for a specific list item may be.
answered Jan 28, 2013 at 16:50
RJ CuthbertsonRJ Cuthbertson
8,3326 gold badges36 silver badges76 bronze badges
2
This error System.ArgumentException: Value does not fall within the expected range with exception message Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName, Boolean bThrow) is due to throttling limit set at List View Lookup Threshold settings in WebApplication.
To resolve this error, Open the SharePoint Central Administration site and click “Manage Web Application” link located under Application Management Group. Select the web application that has the problem. Select the “Resource Throttling” link under the “General Settings”
Navigate to List View Lookup Threshold section and change the value to a higher value depending on the count of Lookup, Person/Group, or workflow status field available in the list that caused the issue.
answered Dec 9, 2015 at 14:31
1