Go To Definition: "Cannot navigate to the symbol under the caret."
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?
I got the same problem. I did all those steps mentioned in all above comments. It didn't work. But when I closed Visual Studio, deleted ".vs" folder (in the solution folder) then reopened Visual Studio. It now works like a charm. The problem is gone.
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:
- Close Visual
- Open Console and navigate to Visual installation folder, in my computer is C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
- run devenv.exe /resetuserdata
- Open Visual Studio, it's going to take some time to load.
Disclaimer: I'm using Xamarin
TAKE INTO CONSIDERATION WHAT @OzSolomon and @xCasper HAVE SAID:
@OzSolomon
Know that this will reset many of your IDE customization, including installed plugins.
Make sure you're comfortable with that before using /resetuserdata
@xCasper
If you have your settings synced through Microsoft, however, most of the preferences seem to restore themselves. I say most because it seems my keybindings did not restore and are back to being default. Everything else, such as my selected theme and colorization choices, the layout of my IDE (where I have tabs for instance), and what not seem to of come back.
I tried David's solution (the one about clicking Empty Symbol Cache option) but it didn't work for me.
How did I solve it?
- Close all files
- Clean solution
- Rebuild solution
For me this error does not make sense but I solved doing this!