“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条回答
Emotional °昔
2楼-- · 2019-01-16 08:25

I faced the same issue and one of colleagues gave me the following solution and it worked! If none of the above works for you,

  1. Remove all the references and add them back (make sure the path is correct)
  2. Go to Solution properties, and recheck the Project Dependencies of all projects. Make sure the project that you'll be using is added as a dependent in the project that you are working on.
查看更多
唯我独甜
3楼-- · 2019-01-16 08:26

In my case, (using Visual Studio Professional 2015), when I had disabled the XAML designer, the F12 stopped working. As soon as I revert the changes, and restart Visual Studio, the F12 worked again.

Checked the pattern multiple times to confirm and then posted. Hope it helps someone.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-01-16 08:27
  1. click on web site menu from VS.
  2. Add reference...
  3. Click on project tab from dialog box
  4. Select ddl
  5. Click on ok button
查看更多
该账号已被封号
5楼-- · 2019-01-16 08:27

Best guess is that you don't have debug information. Maybe you have multiple copies of your assembly on disk and it doesn't have the .pdb file with it.

Do a search for your assembly names from your projects and delete them all and rebuild.

查看更多
Animai°情兽
6楼-- · 2019-01-16 08:28

I did all suggested steps but nothing has been changed then
finally right click and add reference menu, project tab

  1. simply unselected the reference project.
  2. save the solution.
  3. select the same project.
  4. Rebuild the solution.

Problem sorted. Hope this will help to some one.

查看更多
Juvenile、少年°
7楼-- · 2019-01-16 08:28

In my case, I had just recently changed

<mvcBuildViews>

to "true" in my site's .csproj file (to find compile errors in my Razor view files: http://forums.asp.net/t/1909113.aspx?How+to+have+Visual+Studio+2012+returned+compile+errors+on+razor+syntax+error+in+asp+net+web+page+2+ ), and when I then built I was getting errors from my within my site's /obj/Debug/ directory. From any of those files (which were out-of-date), right-clicking and selecting "Go To Definition" would give me the [metadata] version.

So for me, none of the solutions here worked, because I wasn't starting from a file that was actually in my project. Deleted that entire /obj/Debug/ directory, the errors went away, and from any normal file I can correctly use Go To Definition.

查看更多
登录 后发表回答