How can I set a breakpoint in referenced code in Visual Studio?

后端 未结 7 1989
闹比i
闹比i 2020-12-24 05:12

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?

7条回答
  •  心在旅途
    2020-12-24 05:26

    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

提交回复
热议问题