I suddenly started experiencing a problem today in my project where clicking Go To Definition gives me a strange error: "Cannot navigate to the symbol under the caret."
I first noticed it some time after installing Costura.Fody via NuGet. I've since uninstalled it but the problem persists. I've cleaned and rebuilt the solution multiple times. There are no instances of "Fody" or "Costura" anywhere in my git commit history, before or after the point in time when this started happening, so I'm thinking that one of my .gitignore'd files is stuck in a bad state.
The problem only occurs if the definition being targeted is in another file; Go To Definition for something in the currently opened file works fine. Peek Definition works fine too. Other solutions/projects work fine as well -- it's only this one that's causing issues.
I'm using Visual Studio 2015. The issue doesn't seem to occur in the 2013 version.
Why does this error occur and how can I fix it?
For some reason my call_name.xaml.vb class had been excluded from the project (it seemed to happen after I got latest version from TFS). I just had to include it again and it works now!
Most of the paths submitted by others either don't work or are a little backwards.
Empty this folder:
This worked for me.
I've done all things above but my problem did not solve (trying to open project by VS 2017),
after that I realized that the problem was my csproj file. My project (mvc)
was created by VS 2015... So I edit my csproj file and replace
by this :
It was all about the version of DotNetCompilerPlatform.
(the way that I understood this issue was that I created new mvc project by VS 2017 and compared both csproj files - the new one and the one that created by VS 2015 - )
I'm using VS 2017 15.7.5 and this stopped working for certain test files. I noticed that they were all the new ones I had recently added and that in SOlution Explorer there was no arrow available to expand and see the properties / methods.
I excluded and then re-included them into my project and the goto definition command worked again.
The last couple of days I've been getting this error, at least twice a day.. really annoying! None of the solutions proposed here has worked for me. What I found, and since it was pretty difficult to find I'm writing it down here, was to:
Disclaimer: I'm using Xamarin
TAKE INTO CONSIDERATION WHAT @OzSolomon and @xCasper HAVE SAID:
@OzSolomon
@xCasper
Ran into this problem when using F12 to try and go to a method definition.
All of the mentioned items (except the
/resetuserdata
- which I didn't try because it would be a pain to recover from) didn't work.What did work for me:
From a Command Prompt, go to the folder for your solution and run the following code (this deletes ALL bin and obj folders in your solution):
Restart Visual Studio. Opening the solution should take a bit longer as it now rebuilds the obj folders.
After doing this F12 worked!
As a side note, I normally place this in a batch file in my solution's folder, along side the
.sln
file. This makes it easy to run later!