Reputation: 1705
Renaming fails, but only in one of my solutions.
Every time I try to rename a variable/function it prompts for the name change and then fails with the following error:
No references were found in the selected scope. The selected scope is the entire solution so I suspect something is wrong.
I found the following post: https://social.msdn.microsoft.com/Forums/vstudio/en-US/37deb1a5-daa5-47c7-ab50-ed8e57bcf111/rename-class-does-not-work-no-references-were-found-in-the-selected-scope?forum=visualstudiogeneral
But I am concerned that resetting the settings will erase my current settings for each project. I just don't understand why renaming fails only one of the 4 solutions I am working on.
Upvotes: 6
Views: 2813
Reputation: 321
Extending the scope as you and others have suggested will only work in those cases when VS is actually recognizing your references. If "Find All References" (in whatever scope you prefer) works then renaming will also work (if you choose the correct scope).
But many times (happens to me frequently) this is a bug in VS, and unfortunately it's one that's still persisting even today with Visual Studio (Community) 2022 v17.0.5. It can present itself in weird ways, e.g. you can rename some things, but only one time. Other times you can't even rename a single local variable that only appear in two consecutively lines.
More info can be found from this question, and I'll quote the only solution that ever works for me when VS fails to keep track of the references:
- Close out of all instances of visual studio
- Locate the .vs hidden folder within your solution.
- Delete the entire hidden .vs folder.
- Rebuild the solution
Upvotes: 5
Reputation: 11
I got same problem. but when I change Search scope: Entire Solution (including External Items), It works good.
Upvotes: 0
Reputation: 1705
As I mentioned above, the solution is to extend the scope. I am not sure why the scope does need to be extended though. The files are located inside the project and are part of the version control scope for this project.
Upvotes: 2