3

I have a project where the referenced assemblies have symbol files available. Both pdb, and the source files themselves. (they are all my own libraries). The symbols are all listed in the Tools / Options / Debugging / Symbol marking their locations. Thats all fine.

But it's working with them, i'd like to know:

Is there a way in Visual studio to set a breakpoint in a file of the symbol before having to debug line by line to get to the code in question.

To be clear, if i step line by line i can eventually hit the source (because of using the symbol files) code i'm after. But some times getting to that location is not easy, because it's so nested within multiple symbol files. BUT once i eventually step deep enough and find the code, i can set the breakpoint, and from there on stop and start the main application and get to that location without trouble. The file code and all is even listed in the open file pane, for easy view.

Is there any way, if i know the file and line of code i want to break at, open that file in VS and set the breakpoint directly?

Hopefully i was clear in the description. Let me know if i need to reword.

tx

user1161137
  • 1,067
  • 1
  • 11
  • 31

2 Answers2

2

I bet the code you want to put a breakpoint is in a function (;)) so I would use a New breakpoint option from Visual Studio. This allows you to put a method name that VS should break on when entering the method (so basically on the first { after the function name).

After pressing CTRL+B you will be presented with the dialog enter image description here

Here you specify a function name you want to put a breakpoint on.

You can just specify just the name (like. AppendText) or fully qualified name (with namespace - System.Windows.Forms.TextBoxBase.AppendText). If you want to narrow it down to a specific module user module_name!function_name syntax. If needed you can specify on which of the overloaded function you want to break on.

All this info you can get by hovering over an (i) icon on this dialog.

Paweł Łukasik
  • 3,893
  • 1
  • 24
  • 36
0

OK. Knew there had to be a way. And it's very simple.

As stated, if you have the symbol and source available for the Nuget packages you are working with follow these steps:

  1. open the main project in question in Visual Studio.
  2. In VS, click File / Open File...
  3. Under your PACKAGES Folder, locate the package for the reference you want to set breakpoint.
  4. In that package locate the source code folder that was packaged along with the pdb file.
  5. There you will find the source code. Now locate the file you want the breakpoint placed in. Click that file to OPEN the file in Visual Studio.
  6. That file is now OPEN in your VS viewer, but it is not included as a new file in your project (good thing).
  7. Place breakpoint where you want.
  8. Run solution. Now you don't have to step through your entire solution to get to the code you wanted to review with that breakpoint!

what a relief!

user1161137
  • 1,067
  • 1
  • 11
  • 31