Search code examples
c#wpfdebuggingvisual-studio-2019pdb-files

VS 2019 - Debugging .NET Framework Sources


I am not able to step into WPF's source code (PresentationFramework.dll).

I have followed the steps enumerated here.

  • The downloaded sources match the .Net version - 4.7.1.
  • The Modules window says PresentationFramework symbol file is loaded.
  • The break-points do not activate: No symbols have been loaded for this document.
  • Selected break-point's settings says Must match source although Debug Options says otherwise. No change if I switch to Allow the source code to be different from the original.

It looks like it is needed an additional step to associate the source to the PDB.

Thank you

EDIT

I have discovered that I can step into List<T>(). However, what I would like is debugging TreeView & TreeViewItem.


Solution

  • The reason you're not able to step into any source code compiled into PresentationFramework.dll is that PresentationFramework.pdb symbol file that corresponds to PresentationFramework.dll version in your GAC doesn't have any source file paths. It's just the way Microsoft built this particular version of this particular assembly. When they release a new .NET version, they seem to include full debug information (together with source file paths) in PDB files for some of the assemblies, but omit this information from PDB files for other assemblies. I have no idea why they're doing it. On the other hand, you were able to step into List<T> source code because this class resides in mscorlib assembly which PDB file happens to contain source file paths.

    You can inspect PDB files in your symbols cache directory ([your profile]\AppData\Local\Temp\SymbolCache by default) and see which ones contain source file paths and which ones don't. There's no official tool to inspect PDB files, as far as I'm aware, but you may open them with any file viewer, just be prepared that they're binary so what you'll see is mostly gibberish. But you'll still be able to see if there are any symbol sequences that resemble file paths (they're usually close to the start of the file).

    If you really want to step into WPF controls code, there's a workaround described here (I've never tried it myself so I can't vouch for it). The gist is you replace PresentationFramework.dll in your GAC with an older version for which Microsoft built a PDB with full debug information and made it available on their symbol server. To use this approach, you have to know which version you need and where to get it from.