views:

3148

answers:

9

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?

A: 

The only solution I've seen is at: http://johnson1965.blogspot.com/2007/07/visual-studio-2005-go-to-definition-i.html

Chris Lively
A: 

I have the same problem with VS2005, but in C++. There is no C# anywhere in the solution or projects. Yet at least two of my projects, "GoToDefinition" goes to the .h file, never to the function body in the .cpp file.

I would dearly love to find out WHY this is happening.

Mike

I believe it's because Intellisense doesn't work real well with C++. There's been a host of complaints about this.
David Thornley
A: 

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.

Robert Kozak
+5  A: 

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.

Vadim
+8  A: 

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

pfunk
This is great information to have. I'm curious to know whether you guys have SP1 installed?
Chris Lively
well, if I could find that information anywhere on the web I would tell you. I am running VS 2008 9.0.21022.8 RTM, but I'll be damned if I can find anywhere if that corresponds to VS 2008 SP1 or original
pfunk
Great, thanks - this helps me. It should be ProjectReference in csproj file if open it using text/xml editor. Any other should be removed.
Lion_cl
A: 

Hi

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

Tatoba
+1  A: 

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.

Andrew
+1  A: 

This problem can arise when referencing projects that target a different .NET Framework version. Read the post below:

Why Does "Go to Definition" And Intellisense Not Work Properly For Referenced Projects in VS.NET:
http://allen-conway-dotnet.blogspot.com/2010/09/why-does-go-to-definition-and.html

atconway