Cannot Step into .Net Framework Source Code

Cannot step into .NET framework source code


and have a .NET 4.5.2 project

The version number is your problem. It is a general problem with the Reference Source, Microsoft does not keep it updated well enough to supply source for new framework versions. And more troubling, for security and stability updates. The guys that worked on this are well aware of this problem, they noted this as an issue in their presentation but it has currently, and always had, the status of a // todo item.

It is something you can visualize, first delete System.pdb from your symbol cache (the one in MicrosoftPublicSymbols). Then start debugging your test program, the debugger will retrieve a new PDB from the server. Use Debug > Windows > Modules, right-click System.dll and select "Symbol Load Information". On my machine that looks like:

C:\projects2\ConsoleApplication407\bin\Debug\System.pdb: Cannot find or open the PDB file.
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.pdb: Cannot find or open the PDB file.
C:\Windows\System.pdb: Cannot find or open the PDB file.
C:\Windows\symbols\dll\System.pdb: Cannot find or open the PDB file.
C:\Windows\dll\System.pdb: Cannot find or open the PDB file.
C:\temp\symbols\System.pdb\c464b02c2bf04080adcad166dc729c151\System.pdb: Cannot find or open the PDB file.
C:\temp\symbols\MicrosoftPublicSymbols\System.pdb\c464b02c2bf04080adcad166dc729c151\System.pdb: Cannot find or open the PDB file.
SYMSRV: C:\temp\symbols\System.pdb\C464B02C2BF04080ADCAD166DC729C151\System.pdb not found
SYMSRV: http://referencesource.microsoft.com/symbols/System.pdb/C464B02C2BF04080ADCAD166DC729C151/System.pdb not found
http://referencesource.microsoft.com/symbols: Symbols not found on symbol server.
SYMSRV: System.pdb from http://msdl.microsoft.com/download/symbols: 96985 bytes
http://msdl.microsoft.com/download/symbols: Symbols downloaded from symbol server.
C:\temp\symbols\System.pdb\C464B02C2BF04080ADCAD166DC729C151\System.pdb: Symbols loaded.

You can see it searching for the PDB in the normal locations and not finding it. Then contacting the SYMSRV. It first goes to http://referencesource.microsoft.com, as it should, but that server says "not found". And you'll get the copy from the regular msdl server, the stripped one that doesn't have the necessary file + line number debugging info.

There is no clean fix for this, you'd have to downgrade your machine again to the reference source version. Something I cannot do, using Windows 8.1. And should not do, I use VS2013. Redgate's Reflector is an alternative.

I created a UserVoice item for this, it needs a lot more votes.


Update: the Reference Source is now updated to 4.5.2 (March 2015)

Visual Studio Debugger not stepping into .NET framework source code

You can try to use an on-the-fly Symbol Server with dotPeek. It will decompile the assemblies and act as a normal Symbol Server.

Setup the symbol server in dotPeek (Tools -> Symbol Server). Copy the Symbol Server address to the clipboard.

Add this Symbol Server to Visual Studio and remove the other one (or just disable it).

Be aware, it can take a long time to load all .NET assemblies. You can tweak it by choosing Assemblies opened in the Assembly Explorer option in dotPeek.

Extra Instructions: https://hmemcpy.com/2014/07/how-to-debug-anything-with-visual-studio-and-jetbrains-dotpeek-v1-2/

How to debug into .NET framework source code

First of all, I tested it using Microsoft Visual Studio Enterprise 2017, Version 15.9.7 and via .NET Framework 4.7.2. Though, I think it should work on Community edition the same way.

Steps to take:

  1. Go to Tools / Options / Debugging / General, and perform these settings:

    • check Enable .NET Framework source stepping (this will automatically disable "Enable Just My Code"; if not, do it manually)
    • uncheck Require source files to exactly match the original version
    • check Enable source server support
  2. Go to Tools / Options / Debugging / Symbols, and:

    • in the upper listbox check Microsoft Symbol Servers
    • click Empty Symbol Cache button (to make sure you will get the correct symbols)
    • select Load all modules, unless excluded radio button at the bottom
  3. Download the source of the .NET framework version your project is targeting, from the https://referencesource.microsoft.com/download.html site.

  4. Unpack the downloaded archive (zip) file to a convenient path on your PC.

  5. Debug your application; set a breakpoint to the line of .NET code you wish to debug, and step to the desired code line with the debugger.

Note: your application may start slower since it will download PDBs from the internet.


  1. Press Step Into (F11 by default). If your settings are correct, this will cause some delay (if your VS crashes (like mine did), Empty Symbol Cache again). Eventually it will ask for the sources of the given file, e.g. dictionary.cs.
    Two things can happen here:

    • A) It asks for the source file (.cs) in a file dialog. Go to step 7.
    • B) It says whatever.cs not found, and there is a link that says "Browse and find whatever.cs...". Click that link.
  2. Select the corresponding .cs file on your disk (you can search for the file on the OS).

Note: I had to restart VS several times until it "did not crash" while looking for sources, this is most likely a bug in VS.


  1. If you did everything correctly, you will find yourself debugging the .NET source code.

Note: Since VS saves the path you entered for the source files, you can stop debugging or restart VS; it will work next time, too.
Besides, you do not have to manually select any more source files within the framework, because the VS will use the source folder you entered and will search in source files there.

Why F11 don't step into the .NET Framework source code?

At the end the problem was solved unselecting the Microsoft Symbol Server (as the doc said) BUT specifying a Cache symbols directory in that same configuration dialog box, a thing that the doc not said ;)

I'm not able to debug .NET Core source code

Did you enable Source Link? I was able to step into the .NET Core 3.1 source code after doing the following:

  • Uncheck "Enable Just My Code" and check "Enable Source Link support" in Tools -> Options -> Debugging -> General
    Sample Image

  • Activate the symbol servers in Tools -> Options -> Debugging -> Symbols
    Sample Image

I got this information from Improving Debug-time Productivity with Source Link on Microsoft Devblogs.

How do I debug .NET 4.6 framework source code in Visual Studio 2017?

Here is the answer, thanks to Hans Passant. Note that this solution raises additional questions.

  1. Ensure https://referencesource.microsoft.com/ contains the exact version you're debugging.

    • How? Reference source specifies ".NET Framework 4.6.2" but a module version is something like: "4.6.1586.0"
    • You may need to uninstall security updates as explained here: How do you enable "Enable .NET Framework source stepping"?
  2. Configure Visual Studio as specified here:
    https://referencesource.microsoft.com/setup.html

    • Untick "Enable Just My Code"
    • Tick "Enable .NET Framework source stepping" (this should have been the only step needed)
    • Tick "Enable source server support"
    • Untick "Require source files to exactly match the original version"
  3. Confirm symbols are loaded in the Modules window, with source indexing included.

    • How can you tell if source indexing is included? The modules window doesn't specify if a PDB has stripped source information.

Microsoft could make this process a lot more robust by giving helpful error messages instead of silently failing.



Related Topics



Leave a reply



Submit