Visual Studio “Go to definition” disabled or gray out

前端 未结 12 1317
你的背包
你的背包 2021-02-03 21:59

Visual Studio\'s Go To Definition is disabled and F12 doesn\'t work. Other commands like Alt-F12 may continue working.

相关标签:
12条回答
  • 2021-02-03 22:18

    In my case due to my project is mapped with TFS so I am unable to go to definition also my project files showing read only when opening from Solution. So I have move to my root folder mapped with TFS and then right-clicked on folder > Go to properties > Attributes section was Read-Only I have unchecked it and clicked Apply. Reopen visual studio. Everything is now working fine.

    0 讨论(0)
  • 2021-02-03 22:19

    Tried all the above solutions in my VS2019, nothing worked for me. Than I've noticed an update sign on the bottom Right corner. After updating the VS all options were restored.

    0 讨论(0)
  • 2021-02-03 22:24

    I know the solution has been resolved. However, I encountered the exact same problem. I searched internet. None of the trick works including this one.

    Eventually, I figured out. I right clicked on the file that had the problem. I included the file in the project. Isn't that obvious. Actually not, the file has been included for a week. I have been working on that file more than 7 hours a day for the whole week. Up till yesterday 6:20 pm.

    Oh, I could not compile correctly this morning. There were tons of syntax error message yesterday. This morning, I was able to compile. Strange. right? Then my go to definition was gone.

    Took me a while to find out cs and designer.cs were certainly excluded, but aspx file was.

    I solved the problem. Did my figure slip? I don't know.

    That is one thing people check. Either yourself, someone else, or system accidentally exclude the cs files without the knowledge. I know it is strange, but it solved the problem. There are weird scenarios in Visual studio. People can present 200 solutions. They work for 99% of time, but not our cases. I just bring one more scenario

    0 讨论(0)
  • 2021-02-03 22:24

    I encountered this in Visual Studio 2010. For me, this solution did the trick

    1. Close all the files.
    2. Reopen the files.

    and you are good to go.

    0 讨论(0)
  • 2021-02-03 22:28

    I've just had this happen with a CMake-based C++ project in Visual Studio 2019. Everything was fine yesterday, then when I opened it up today all the Go To Definition/Declaration etc options were greyed out everywhere in every file in the project, even for things defined within the same file (and the syntax highlighting didn't look right either). It did work if I opened one of the .cpp files separately on its own (without loading the Project/Solution).

    I tried various things including the answers here and telling it to generate the CMake cache again, but what finally fixed it was actually deleting the CMake cache. The Delete Cache option didn't seem to work (all the files were still there on disk, and there was some sort of failure message in the Output window) so I just deleted the entire "out" directory from the project directory (well, moved it somewhere outside of the project, just in case). Loaded up Visual Studio again, it rebuilt the cache again automatically and IntelliSense immediately started working again! I just had to wait 5 minutes for it to compile everything again when I wanted to run the project.

    Maybe it wasn't necessary to remove the entire "out" directory, but when I clicked "Open in Explorer" under the "CMake Cache" menu it opened the actual build directory (which was the only thing in the "out" directory anyway) so I assumed the entire thing was related to the cache and was getting too fed up with it to try to narrow it down further. It's probably only certain files within that directory really.

    0 讨论(0)
  • 2021-02-03 22:29

    I faced the same Issue in my Visual Studio 2019 version.I followed the below Steps:

    1. Go to references folder in the solution.

    2. Click on Manage Nuget packages.

    3. Click on Browse.

    4. Search for 'Microsoft.Net.Compilers'.

    5. Click on Update.

    This Worked for me.

    0 讨论(0)
提交回复
热议问题