20

Since I do not have access to the complete source code of a library I'm using, but I do have the pdb files, is it possible to set a breakpoint in the "debugging source code"?

If so, how would I do that?

1 Answer 1

30

Yes, this is possible, you don't need the source code. Debug > New Breakpoint > Break at Function. Set the location to the name of the function. For example: "Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly". Turn the "Use Intellisense" checkbox off, you won't have any. Language is a guess if you don't know what it was written in, choose "Unknown" if you're not sure.

You'll want to keep an eye on the Debug + Windows + Breakpoints window to verify that the debugger could resolve the breakpoint. It won't be able to until the assembly gets loaded and the method gets JIT compiled.

This is of course not the greatest debugging experience. Once the breakpoint hits, you don't have anything to look at but the machine code generated by the JIT compiler. And the Call Stack window, your ultimate resource to see method names btw.

5
  • So how would you set a break to e.g. System.DateTime.IsLeapYear()? Tried this but it's not breaking. I have the 'Microsoft Symbols Servers' defined in Tools > Debugging > Symbols, but the Breakpoints window shows 'Symbol not found'.
    – Rubio
    Mar 7, 2013 at 11:17
  • Works fine when I try it. Don't type the () Mar 7, 2013 at 11:20
  • 3
    Had 'Just my code' set (again, sigh) so the symbols didn't get loaded. Just need to load the source code. I understand John Robbins has a tool for that.
    – Rubio
    Mar 8, 2013 at 13:17
  • 2
    VS almost always goes above my expectations. Setting a breakpoint to an external funcion and looking at the CallStack was I all needed to fix a complex issue. Thanks for the answer. May 11, 2016 at 9:01
  • For me, it worked best by including the the dll as well, like Microsoft.AspNetCore.Authentication.Certificate.dll!Microsoft.AspNetCore.Authentication.Certificate.CertificateAuthenticationHandler.HandleAuthenticateAsync(). You can copy this entire string from the callstack.
    – martinoss
    Oct 28, 2020 at 14:23

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.