How do you enable "Enable .NET Framework source stepping"?

Update 22nd Feb 2013 : The Microsoft Connect entry has note from Alok Shriram (Program Manager, Base Class Libraries, .NET Framework) that the issue should now be resolved. The Connect entry is marked as Resolved (Fixed):

This issue should now be fixed. We published an update to reference sources. Please let us know in case your issue is still not fixed.

Year and a half.

Bonus Links

  • Vote that this bug be fixed on Microsoft Connect.

  • Thread on Microsoft Social that has been going for a year and a half, asking when it will be fixed.

  • Original Question

    How do I enable .NET framework source stepping in Visual Studio 2010?


    Note : This question is one piece of a larger whole:

  • .NET 2.0 WinForm: Supporting DPI and Default Font Changes
  • WinForms controls do not scale during ScaleControl
  • VS2010: How to enable "Enable .NET Framework source stepping"?
  • Visual Studio 2010 Professional: How to access Modules window?
  • Visual Studio 2010: Properties.Settings broken after retargetting project to .NET Framework 3.5

  • Visual Studio 2010 comes with a new feature:

  • Tools, Options, Debugging, General, Enable .NET Framework source stepping
  • 选项菜单的屏幕截图

    Following the instructions on the MSDN page How to: Debug .NET Framework Source:

    To enable .NET Framework source debugging

  • On the Tools menu, click Options .

  • In the Options dialog box, click the Debugging category.

  • In the General box, select the following check boxes:

  • Enable .NET Framework source stepping
  • Enable source server support
  • I do this:

    选项菜单的屏幕截图,突出显示所选的相关选项

    Note : You will note, as the MSDN page notes, and as I noticed, that checking Enable .NET Framework source stepping will automatically uncheck **Enable Just My Code (Managed only). I also enabled the diagnostic messages of source server support.

    Enabling those options automatically set a symbol cache download location for me:

    选项菜单的屏幕快照,显示缓存目录(突出显示)

    Note : The Microsoft Symbol Server entry is already present (and cannot be removed).


    The MSDN page says to load the symbols:

    To load Framework symbols using the Modules window

  • In the Modules window, right-click a module for which symbols are not loaded. You can tell if symbols are loaded or not by looking at the Symbols Status column.

  • Point to Load Symbols From and click Microsoft Symbol Servers to download symbols from the Microsoft public symbols server or Symbol Path to load from a directory where you have previously stored symbols.

  • I try this:

    在这里输入图像描述

    and then all the symbols are loaded:

    如上所述,模块窗口的屏幕截图

    I've been sitting on a breakpoint, which is about to call into .NET framework code:

    protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
    {
        base.ScaleControl(factor, specified);
    

    Pushing F11 causes the debugger to simply skip to the next line:

    protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
    {
        base.ScaleControl(factor, specified);
    
        //Record the running scale factor used
        this.scaleFactor = new SizeF(
                this.scaleFactor.Width * factor.Width,
                this.scaleFactor.Height * factor.Height);
    

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    I am sitting at a breakpoint in my code. I try double-clicking on a function further up in the call stack. This would, I hope, allow me to jump to the .NET code:

    在这里输入图像描述

    Except that it doesn't work: Visual Studio tells me that there's no source available:

    错误消息的屏幕截图显示无源可用

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    If I switch to disassembly view before trying to step into .NET code ( Debug -> Windows -> Disassembly ), I can see a call into the .NET code:

    And when I do, I end up debugging a disassembly of System.Windows.Forms.ScaleControl :

    反汇编窗口的屏幕截图

    Which isn't the same as, or as useful as, being able to step into the .NET Framework source.

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    The configured symbol cache path on my computer does contain symbol cache files:

    文件夹清单的截图

    So it is downloading pdb symbol files, but refusing to use them.

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    Leppie suggested that I check the Debug log (with the debug log window open; otherwise it doesn't log anything):

    Step into: Stepping over method without symbols 'System.Windows.Forms.Form.ScaleControl'
    

    Earlier in the log I see it loading symbols for System.Windows.Forms.dll :

    Loaded 'C:WindowsassemblyGAC_MSILSystem.Windows.Forms2.0.0.0__b77a5c561934e089System.Windows.Forms.dll', Symbols loaded.
    

    在这里输入图像描述

    So it is finding my symbols, but claiming that it couldn't find them.

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    A guy from Microsoft Italy suggests turning off Require source files to exactly match original version :

    选项窗口的屏幕截图

    That didn't fix it.

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    It has been suggested that there's a bug with Microsoft's source server for .NET Framework 4.0 . Following that suggestion, I switched the project to target .NET Framework 3.5 :

    在这里输入图像描述

    That didn't fix it.

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    Someone somewhere idly wondered whether another person experiencing the same problem was using the 64-bit version of the debugger. Now, there's no such thing as a 64-bit version of Visual Studio, but I tried switching my project from AnyCPU to x86 (it was being JITed to x64), in case Microsoft doesn't support 64-bit processors:

    在这里输入图像描述

    That didn't fix it:

    Step into: Stepping over method without symbols 'System.Windows.Forms.Form.ScaleControl'
    

    How do I enable .NET Framework source stepping in Visual Studio 2010?


    See also

  • Configuring Visual Studio to Debug .NET Framework Source Code
  • Unable to debug .NET framework code in VS2010
  • .NET framework source stepping not working despite options set
  • Setting up Visual Studio 2010 to step into Microsoft .NET Source Code
  • Visual Studio 2008 SP1 .NET Framework Source Debugging
  • No Debug>Modules window in Visual Studio 2008 Version 9.0.21022.8 RTM

  • The PDBs for stepping through the source code are only posted for RTM and Service Packs. As such, when security update comes out and it modifies the dll you are trying to debug, it will cause source stepping to not work (that is, you'll get the "No source Available" with a greyed out "Browse to find Source").

    However, once you've made all the appropriate settings, you can use the following workaround. The workaround is essentially to find the security updates that caused the dll to change, and then remove them. This has the obvious downside of having those security updates removed on your machine.

    Workaround

  • Identify which dll you want to debug into (eg System.Windows.Forms.dll)
  • While debugging, open the Modules window in Visual studio, find the Version column. If the version is not the RTM or Service pack version, then you'll need to do the workflow. Typically the RTM dll will say "built by: RTMRel". While a dll that was part of a security update will say "built by: RTMGDR". Note the version number (for example 4.0.30319.269 built by: RTMGDR)
  • Now, we want to find the update that created this version. Do this by searching for the dll and version number at support.microsoft.com/kb/ For example, I did the following google search: site:support.microsoft.com/kb System.Windows.Forms.dll 4.0.30319.269
  • The search should turn up information about an update. Note the KB number in the address bar. In my example the address was http://support.microsoft.com/kb/2604121 , so KB2604121, is what we're interested in.
  • Go to Control Panel->Programs and Features, and click "View Installed Updates"
  • Find an update which lists the KB number (you can use the search in the upper right box).
  • Uninstall that update.
  • Repeat this process for this same dll until the dll is back to its RTMRel version or SP version. For example, for System.Windows.Forms.dll, I had to remove KB2686827, KB2604121, KB2518870 before it was back to the RTMRel version.
  • You'll need to do this for each dll within the .NET framework that you care about debugging into.

    Once that's done, set a breakpoint within the .net source (for example, go to the Breakpoints tab, say New->Break at Function, and enter System.Windows.Forms.Form.Form) or step into one of the .net methods in that dll.


    While unfortunately there is a problem with a Microsoft, as Leppie pointed out (and I got the same result see

  • "No Source Available" - Visual Studio Debugging (even when symbols have loaded))
  • it should be noted that your attempt would fail anyway, since you referenced:

  • Microsoft Symbol Server
  • instead of:

  • referencesource.microsoft.com/symbols
  • See the FAQ/Troubleshooting section of Configuring Visual Studio to Debug .NET Framework Source Code


    I have found the answer, I think.

    I traced what was happening on Fiddler. It seems only the symbols are currently available, and no source.

    When VS tries to load the symbols from the 'referencesource' server it fails (404). As this fails, I think it cannot map to source files on that server.

    http://referencesource.microsoft.com/symbols/mscorlib.pdb/ED96A7F38A2940F39B9CA7AD9BC5CB671/mscorlib.pdb

    After the above failure, it tries some server called 'msdl' where it finds the actual PDB (but it appears this one have no source code info).

    http://msdl.microsoft.com/download/symbols/mscorlib.pdb/ED96A7F38A2940F39B9CA7AD9BC5CB671/mscorlib.pd_

    All in all, it appears to be a (temporary) Microsoft issue with their servers.

    I am sure I had some source code a while back. But now it is not working.

    Edit:

    I tried it with various .NET versions, all the same result. :(

    链接地址: http://www.djcxy.com/p/12938.html

    上一篇: 如何更新符号(.pdb)文件中的源位置

    下一篇: 你如何启用“启用.NET Framework源码步进”?