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?
单击Debug,New Breakpoint,Break at Function,然后输入函数的全名。
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.
You can do one of the following:
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.
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
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.
follow these steps:
Debug
New Breakpoint
Function Breakpoint
or simple press the Ctrl+K, B
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: ABCD
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:
MyClass.SomeMethod
anywhere in your own code / test fileMyClass.SomeMethod
you typed at step 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.