"Value does not fall within the expected range" when trying to add a reference in a project
Asked Answered
F

16

74

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?

enter image description here

Fourwheeler answered 28/5, 2014 at 1:32 Comment(1)
If you're getting this error, make sure you look in your Output window and flip through the various Build/General dropdown options for Output. I found additional details after the error message, about which tag in my project file was causing the failure, which helped troubleshoot.Hoban
F
85

I did a 'devenv /setup' and that fixed it.

Detail

  • Exit Visual Studio
  • Click Start
  • Type cmd, right click Command Prompt and select Run as administrator
  • Navigate to the appropriate Visual Studio folder
    VS2012: pushd %programfiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE
    VS2015: pushd %programfiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE
    VS2017: pushd %programfiles(x86)%\Microsoft Visual Studio\2017\<Edition>\Common7\IDE
    VS2019: pushd %programfiles(x86)%\Microsoft Visual Studio\2019\<Edition>\Common7\IDE

  • Type devenv /setup and 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

Fourwheeler answered 28/5, 2014 at 1:40 Comment(14)
fyi: the path for Visual Studio 2015 is: pushd %programfiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDEAlterable
I can't believe it but that's working! My issue was simular but I get the error while editing some property a WinForm object using non-ascii value.Quasar
Correct path for VS2012 is pushd %programfiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE . What was listed is true for VS2013.Pricefixing
In my case the error occurred when trying to close a code window. devenv /setup fixed it as well.Fillender
This solution can also solve the trouble around Property Sheet.Kettledrum
I had to run the "Developer Command Prompt for VS 2017" (which was installed with Visual Studio 2017) as Administrator, and then run devenv /setup from any directoryGinelle
What does devenv / setup do??Hassiehassin
@Tim, Why not click his link and find out?Electroballistics
@NickG: I did, but the explanation given there was rather skimpy.Hassiehassin
Unfortunately this suggestion did not work in my case.Monophagous
I try it also, not work for me too, and then I search the project files, and I write an answer for my case - seems that this message did not help at all and is for many different issuesSend
Same here, unfortunately I'm still in the same state. :<Akins
deven /setup was not recognized. I typed deven and tab so it turned to deven.com and put the /setup there. The command seemed to run but unfortunately did not solve my problem in VS then.Lisettelisha
cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE" .\devenv.exe /setup Teazel
B
45

In my case deleting .suo file in \.vs\[solutionName] folder fixed the problem in Visual Studio 2022

Briarwood answered 9/8, 2022 at 5:43 Comment(6)
in my case my project was not opening. now it works! thanksCapital
I just ran into this as well. I think it has to do with switching git branches and VS gets all confused.Necrophilism
In my case I just deleted the entire .vs folderOrthognathous
In my case I found your solution and it worked... thanksRenewal
This worked for me too. Deleted the whole .vs folder and after reopening the solution it worked!Unbeatable
Couldn't open a solution after my computer crashed. This did fix itFilomenafiloplume
F
13

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> to true
  • Set <UseIIS> to false
  • Then reload the project.

(after that you can set your local IIS again)

Festoon answered 21/2, 2020 at 14:31 Comment(0)
M
11

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.

Mccrory answered 10/10, 2019 at 11:21 Comment(1)
This worked for me. I upgraded from VS 2017 to 2019 and forgot to set my shortcut to run as administrator. I have to run as admin because two of my projects use IIS.Amphora
S
7

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.

Selfassured answered 26/8, 2022 at 6:46 Comment(3)
Nice, that worked for me!Kyoko
same. In my case it was throwing an exception after PC got shut off unexpectedly. Removing .vs folder fixed it.Dapple
I was experiencing the same problem when trying to open a C++ solution/project in VS 2022. By deleting the .vs folder, it fixed the problem.Tonsillotomy
M
2

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.

Marathon answered 9/10, 2019 at 21:39 Comment(1)
In my case this specific version was defined in the projects global.json.Crissie
S
2

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.

Send answered 20/9, 2020 at 19:49 Comment(0)
B
1

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.

ECommerce\Prod\EcommerceUtility\ECommerceCommands\ECommerceCommands.csproj : error : The imported project "C:\Program Files (x86)\MSBuildExtensionPack\4.0\MSBuild.ExtensionPack.tasks" was not found.

Confirm that the expression in the Import declaration "C:\Program Files (x86)\MSBuildExtensionPack\4.0\MSBuild.ExtensionPack.tasks" is correct, and that the file exists on disk.

Bedlam answered 23/2, 2021 at 17:5 Comment(0)
B
0

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,

  1. Double click on the file and open it
  2. Right click on the file and select "Start with Debugging" or "Start without Debugging"
Billposter answered 18/7, 2019 at 13:59 Comment(0)
A
0

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.

Agbogla answered 19/8, 2019 at 5:8 Comment(0)
A
0

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.

Agonize answered 15/6, 2020 at 12:3 Comment(0)
D
0

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 : )

Drupelet answered 25/6, 2020 at 11:6 Comment(0)
R
0

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.

Rogerson answered 21/6, 2021 at 15:38 Comment(0)
C
0

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>
Cytochemistry answered 22/3, 2022 at 2:39 Comment(0)
R
0

In my case, the issue was caused because the project required the older version of the .NET SDK.

So, what I did was to open the "Visual Studio Installer" and, in the "Individual Components" section, chose the previous version of .NET SDK (although they were out of support in my case).

Refrigeration answered 2/3, 2023 at 9:22 Comment(0)
M
0

In my case I deleted .vs folder and restarted the application then it started to work!

But I have to add that I wrote code and used hot reload instead of whole application restart, so when I restarted the application it self maybe this helped if no then .vs folder deletion helped.

Mccurdy answered 23/5, 2023 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.