19

I have a C# project which contains references to assemblies in DLL format. I have the PDB information for these DLL files, contained in the same folder. When I press F12 on a referenced member, I want to go to the definition of the member. Instead, it gives me the metadata, which of course I don't want.

When VS is debugging, it does go to the source code if I single step into that method. But if I press F12 on that method, it still brings me to the metadata.

There is a similar question here, but it only applies to project references, and the accepted solution has nothing to do with my issue.

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

To summarize:

  • Referenced project is a DLL
  • I have the PDB information
  • Single-stepping in debug-mode brings me to the source code
  • F12 brings me to metadata
  • I want F12 to bring me to the source code as debug does.

EDIT: Adding as a "Project" is not an option as it creates additional complexity as our solution file references about five other projects which are all under separate source control repositories.

Community
  • 1
  • 1
marknuzz
  • 2,847
  • 1
  • 26
  • 29

7 Answers7

13

In Visual Studio expand the References section, select the reference to your related project (the one that contains the source code you want to F12 into) right click on it and select "Remove".

Then add the reference back to the project by right clicking on References and selecting Add Reference, under the Projects tab (if your using VS 2012) select (or browse for) the project you want to add a reference to and then click the OK button.

This will rebuild the reference and you will be able to F12 into the referenced projects source code. You will need to do this with all the projects in your solutions that are having this issue.

I don't know why this happens but at least the solution to the problem is rather simple

mknopf
  • 370
  • 4
  • 11
  • 3
    -1: This question is regarding references where the "Project" file is unavailable, and only DLL & PDB files are present. Your answer requires project files and full sources, which do not fall under this category. – marknuzz Aug 27 '13 at 01:47
  • @JosephWhite the question you were looking for is here then, http://stackoverflow.com/questions/837037/go-to-definition-in-visual-studio-only-brings-up-the-metadata please upvote that answer and downvote this miscategorized one. This site becomes less useful when similar (but different) questions are treated equally. – marknuzz Oct 05 '14 at 08:47
  • Nice one bro (Y) Worked for me – Scott Allen Nov 27 '15 at 11:45
  • FYI: I had the same problem in VS 2017 and this solved it. – BernieP Mar 07 '18 at 16:28
8

If you have ReSharper installed, you should bring up ReSharper options, and look for External Sources. There you can specify the relevant options:

enter image description here

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158
4

It appears that this issue has been solved in Visual Studio 2013. Having the PDB information in the same folder as the DLL is showing me the source code when I use Go To Definition. I do not have the Reflector extension installed.

marknuzz
  • 2,847
  • 1
  • 26
  • 29
2

Is the referenced DLL a project in your solution? I find that when I have the source code for the project, and it's in my solution, Visual Studio is able to link to this code much more easily. (without showing me meta data).

Also, be sure to add the reference by "Project" in the References popup.

This is generally what I do anyways when I have this problem

Hope this helps!

PS. PDB files are usually just for debugging (both locally and remote) and are not used for source code reading in the way you are attempting to use it. ("Go To Definition")

Andrew White
  • 864
  • 5
  • 6
  • 1
    That's not an option, sorry. I'm looking for a solution and not a band-aid. – marknuzz Nov 02 '12 at 23:56
  • 2
    Sorry to hear that. Good luck with whatever you choose to do. This isn't a band-aid, however. A lot of people in your situation do this all the time to solve their problem. – Andrew White Nov 03 '12 at 07:15
  • I said in the question that the answer in the linked question had nothing to do with my issue. That answer is essentially the same one you gave. This is a different issue. – marknuzz Nov 05 '12 at 19:05
1

One solution to this issue is to use .NET Reflector, VS or VSPro edition. This program will modify Visual Studio to provide the required functionality.

http://www.reflector.net/

Unfortunately, it costs $135 to $195, which isn't an option for everybody.

marknuzz
  • 2,847
  • 1
  • 26
  • 29
  • this is probably the easiest solution, although it will cost $. The VS add on for Reflector allows you to F12 into any referenced DLL, regardless of having the source code or not – mknopf Apr 09 '15 at 22:34
-1

Add the reference as a project instead of ..\bin\Debug\referenceFile.dll

That solved my issue

-1

I also used add reference as a project and my problem has been resolved and it's working great. Actually I was stuck at this point from very long time and finally i resolved this issue.

References -> Add References -> Solution -> Projects -> Select reference

enter image description here