Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Go To Definition" in Visual Studio only brings up the Metadata

Well, another developer found the answer. The specific project we had an issue with was originally added as a file reference, then removed and added as a Project Reference. Visual Studio however, kept both in the csproj file for the web site, causing the issue. He went in and manually edited the csproj file to remove the file reference to the problem project and all is fixed now


It happens when you don't add reference as a project but point to a dll or exe using Browse tab in Add Reference dialog. If you add reference using Projects tab you should go directly to the source code when you select Go To Definition.

However, if you install ReSharper, you'll go to source code even if you added your reference to a dll/exe using Browse tab.


Looks like it needs to be setup in Resharper as well. My Visual Studio does not navigate to .NET Framework source code until I enable it in Resharper.

Resharper settings to allow navigate to external source


1. close your solution.

2. delete hidden <name of the solution>.suo file in folder where your solution's <name of the solution>.sln file exists.

3. open your solution.

4. rebuild your solution.


For those using VS 2017 (I'm at version 15.3.4 at this moment) here are the simple steps:

  1. Open your solution in Windows Explorer and close down Visual Studio
  2. In the explorer menu, select View and ensure that the "Hidden items" checkbox is marked
  3. Navigate to the subfolder .vs\[your solution name]\v15
  4. Delete the .suo file
  5. Restart VS and build your solution

That fixed it for me: F12 opened the actual source file, not the "from metadata" version.


Visual studio often suffer from a problem of going to metadata rather than your project if you shift location where you are building the project, ie you may have several versions to test things out.

Simply delete the reference and immediately add it back and everything will be sorted out.


The marked solution does not always work. You must make sure that the referenced project GUID in the project files is the correct GUID for the project you are trying to reference. Visual Studio does allow them to get out of synch in some circumstances. You can get the project GUID from the project file with a text editor. So if project A reference project B. Open up project B.csproj in text editor, copy out project GUID from the tag. Then open up project A.csproj in text editor, and make sure that you are using the correct GUID. Search for project name "B" in this case. It should be at . Replace the GUID in the tag with the correct one. Save and reload. Of course also make sure file based references to your projects are removed. You only want project references.