27

I am fairly new to Visual Studio, coming from Java development on Eclipse. Among other things I sorely miss from Eclipse is an ability to view source of binary assemblies.

In Eclipse I can attach reference to source code for a referenced jar and after that it is dead easy to navigate to the source, add breakpoints and debug those as though I have the libraries in my workspace.

Up to this point I have not managed to attach source code to an assembly reference.

Is it possible? How do I go about doing that (given that I do have access to the source code for this library)?

3 Answers 3

11

Using VS2010 - you will first need to compile your referenced assemblies with debug symbols.

A couple of options are then:

  1. Find an object which you want to debug in Object Browser. Right click -> Navigate To -> Sources From Symbol Files.
  2. Step through your code until you step into the referenced assembly. At this point a dialog will pop up asking where the source files are. If it doesn't, or you cancelled it, then a "Browse to Find Source" will appear on the right. If this is greyed out, then that may be because you are referencing a release assembly.
1
  • 5
    I don't see Sources From Symbol Files. I believe it's a Resharper feature. Commented Feb 26, 2013 at 20:05
5

If you use ReSharper, you can enable it by going to ReSharper / Options / External Sources, and move up "Sources from symbol files". Then in the tab "Sources from symbol files", click "Advanced" and there you can map source folders.

This is a copy of the answer here, but I wanted to include it here so if you, the reader, have stumbled upon this link you have the answer too.

1
  • 1
    What means source and target folder in that ReSharper configuration?. Commented Mar 1, 2019 at 17:01
0

The quickest way: If you have source code to these assemblies. Add that source code as a new project to your current solution so that the assembly project and your referencing project are part of single solution.

Now add reference to assembles in assembly project from Add reference and select 'Projects' tab.

Put breakpoints in your assembly source code, and start debugging and have fun!.

Use 'step into' or F11 and breakpoints will be hit when referenced in source code.

2
  • 8
    Thanks, but this will not do. I still need to define my dependency from the binary assembly, not the source code (I've pulled in the depencency with NuGet package manager). The fact that I have the source should only serve as a help for my debugging and code archaeology needs... Commented Mar 21, 2011 at 9:09
  • 6
    Furthermore - I use CI server to build my solution and having source projects for most external dependencies is going to needlessly grow build times for my solution. Commented Mar 21, 2011 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.