My main solution is using code from a utility class library, that I wrote myself, but is a part from another solution. How can I set a breakpoint in the referenced DLL file?
8 Answers
Click Debug, New Breakpoint, Break at Function, then enter the full name of the function.

- 868,454
- 176
- 1,908
- 1,964
-
2I couldn't get this to work under VS2012 since it said it couldn't verify the function. It seemed to be able to find functions within the solution but not in referenced libraries. – Sam Sep 08 '14 at 05:21
-
8It's clear to me now, but remember to include the full namespace of the function excluding the parenthesis. – Phil Cooper Jul 05 '15 at 07:31
-
How does this work if I have a function with the same name in two separate files? When I type in the name and click OK, a window pops up listing 2 files I could set a breakpoint in. While they both define a method with the name I entered, neither are the one I'm trying to debug. – sab669 Jun 01 '17 at 16:06
-
1You need the PDB for this. Luckily even if you don't have a PDB you can generate it. See: https://stackoverflow.com/a/31286658/67824. – Ohad Schneider Aug 07 '17 at 13:25
-
@SLaks not for me it didn't. I guess this mechanism is not perfect: https://github.com/Microsoft/ApplicationInsights-Home/issues/152#issuecomment-320719671. – Ohad Schneider Aug 07 '17 at 23:59
-
Anyone knows how to set function breakpoint for Constructors of the class in the referenced libraries? – Pratik Aug 02 '19 at 17:40
-
1@pratiksanglikar: IIRC, `Namespace.ClassName.ClassName` – SLaks Aug 05 '19 at 16:08
-
1@pratiksanglikar: Try `Ns.ClassName.ctor` – SLaks Aug 05 '19 at 17:44
In Visual Studio open the source file of your referenced DLL that contains the desired method manually using menu
File > Open > File...
Then set the breakpoint by clicking on the left border in the code editor. This enables you to break at any code line and not just at function calls. Visual Studio shows the breakpoint in a kind of disabled state, because it thinks that the code is unreachable. Just ignore it; the breakpoint will become active once the code runs and the DLL has been loaded.
Note: you must reference a Debug version of your assembly for this to work.

- 104,806
- 13
- 138
- 188
You can do one of the following:
- Add the DLL project to the solution containing your executable. Then you can set breakpoints as normal.
- You could instead just open the DLL project and use the Debug -> Attach to Process to attach to your running EXE

- 68,005
- 14
- 144
- 156
-
15(2) I find easy - just run two instances of Studio side by side. Ctrl-F5 on the 'primary' one to lauch wihtout the debugger attached, then attach to the process with the instance of studio that is editing the library project. – Frep D-Oronge Sep 12 '11 at 13:54
-
2Frep D-Oronge, you should add that as an answer - it seems the easiest overall approach. – Tim MB Sep 19 '12 at 11:58
-
@FrepD-Oronge Wish i could have read your comment 2 hrs 39 min back. You rock ! Its definitely the most easiest solution. – Nova Mar 29 '17 at 04:56
I know this is an old question, but may be of help to many.
For the debugger to work correctly, you need to load debugging symbols database, a .pdb file with the same name as the assembly you want to debug. If it's part of a solution you created you could just copy-paste it from the other solution's bin folder. Then add a breakpoint specifying the full path to the method you want to debug, plus the name of the assembly it lives in. EX: "MyNamespace.MayClass.MyMethod, MyAssemblyName"
If you don't own the code you have 2 options, both involving a dissasembler. I use dotPeek for this, since it really rocks.
Option 1: you open the assembly with dotPeek and create a single .pdb for that, then copy it to your .bin folder and follow the steps above. https://www.jetbrains.com/decompiler/help/Generating_PDB_Files.html
Option 2: use dotPeek Symbol Server and PDB Generation. https://www.jetbrains.com/decompiler/help/Symbol_Server_and_PDB_Generation.html After that follow the instructions above to attach a debugger instance.
Hope this helps

- 579
- 7
- 18
-
-
There's also a tool that can fetch the PDB directly from symbol servers (configured against the official MS symbol server [http://msdl.microsoft.com/download/symbols] by default): https://github.com/rajkumar-rangaraj/PDB-Downloader. – Ohad Schneider Aug 07 '17 at 16:50
-
https://www.jetbrains.com/decompiler/help/Symbol_Server_and_PDB_Generation.html is broken. – David Klempfner Nov 27 '20 at 12:15
Make sure you have the .pdb file in the bin/debug folder where the referenced class library dll resides. When you are debugging your current solution you should be able to step into the code from your class library. When you step into the class library you will be able to set breakpoints.

- 9,286
- 1
- 23
- 25
follow these steps:
- Go to
Debug
- Go to
New Breakpoint
- Click on
Function Breakpoint
or simple press theCtrl+K, B
- a window shows up, type the function name in the following format:
namespace.ClassName.FunctionName
For example, assume that you have a code like this and I want to put a breakpoint at the beginning of function D
:
namespace A.B{
public class C{
public void D(){
int x= 10;
}
}
}
So in Function Breakpoint
window you need to type: A::B::C::D

- 4,728
- 8
- 44
- 68

- 6,081
- 7
- 42
- 62
This is not my own answer, it was Frep D-Oronge's suggestion in one of the comments above. It is easy and works with no hiccups:
"I find easy - just run two instances of Studio side by side. Ctrl-F5 on the 'primary' one to launch without the debugger attached, then attach to the process with the instance of studio that is editing the library project"
All credits are due to him.

- 2,310
- 6
- 25
- 52
Let's say you want to debug SomeMethod
located deep inside a NuGet package you depend on.
In that case, a simpler approach is to:
- Type
MyClass.SomeMethod
anywhere in your own code / test file - Control+click on "SomeMethod", Visual Studio will open "MyClass.cs"
- Add your breakpoint
- Go back to your code and delete
MyClass.SomeMethod
you typed at step 1 - Click "Debug"

- 703
- 7
- 10