“Go To Definition” in Visual Studio only brings up

2019-01-16 08:02发布

I am working in a Web Project in Visual Studio 2008. When I hit F12 (or right-click and select Go To Definition) Visual Studio is consistently going to the Meta data file instead of going to the source.

Some Points:

  • All the source code is C#, there is no VB.Net
  • All the projects are in the same solution
  • Yes, everything is a project reference (checked and double-checked)
  • I have tried the Clean/Rebuild Solution approach (even to the point of clearing out the Temp directory, Temporary ASP.NET Files directory, etc).

Has anyone else seen this behavior and/or know how to fix it?

24条回答
闹够了就滚
2楼-- · 2019-01-16 08:33

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.

查看更多
叼着烟拽天下
3楼-- · 2019-01-16 08:33

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.

查看更多
萌系小妹纸
4楼-- · 2019-01-16 08:33

Symptom:

Visual Studio 2010 Ultimate was repeatedly failing to find references to functions, #defines, includes, etc when using the "Go To Definition" or "Go To Declaration" or "Find All References" features - oddly Intellisense was working.

Fix:

  1. Close Visual Studio
  2. Delete (rename if you want to be conservative) the solution .sdf file
  3. Reopen Visual Studio

The .sdf file will automatically be rebuilt by parsing the include files in your solution

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-16 08:33

Just found another cause. I upgraded my web project to 4.0 but left the class libraries at 2.0. At that point all the class libraries in my solution were treated as file references from my web project. Might help someone else...

查看更多
在下西门庆
6楼-- · 2019-01-16 08:34

Remove the reference dll, Build (will get errors), ADD THE reference (you removed) then build again ... F12 on your function should then work (worked for me).

查看更多
姐就是有狂的资本
7楼-- · 2019-01-16 08:34

Below steps worked for me.

  1. Go to .csproj file
  2. Open it in Notepad Go to line where dll is referred.<Reference Include="">
  3. Delete the line

    <SpecificVersion>False</SpecificVersion> 
    or 
    <SpecificVersion>True</SpecificVersion>
    
查看更多
登录 后发表回答