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

9

122

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

Original Question

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


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


Visual Studio 2010 comes with a new feature:

  • Tools, Options, Debugging, General, Enable .NET Framework source stepping

Screenshot of options menu

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

To enable .NET Framework source debugging

  1. On the Tools menu, click Options.

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

  3. In the General box, select the following check boxes:

    • Enable .NET Framework source stepping
    • Enable source server support

I do this:

Screenshot of options menu, highlighting the relevant options selected

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:

Screenshot of options menu, showing cache directory (highlighted)

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

  1. 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.

  2. 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:

enter image description here

and then all the symbols are loaded:

Screenshot of modules window, as described above

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

Screenshot of code, transcribed below

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

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

Screenshot of code, transcribed below

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:

enter image description here

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

Screenshot of error message saying 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:

Screenshot of code

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

Screenshot of disassembly window

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:

Screenshot of folder listing

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:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Symbols loaded.

enter image description here

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:

Screenshot of options window

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:

enter image description here

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:

enter image description here

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

Boneset answered 15/11, 2011 at 16:0 Comment(13)
Have you checked the source code 'cache' ?Piazza
@Piazza What do you mean by the "source code 'cache'"? If you mean the folder that caches the source code in, it is being populated (See Update 4)Boneset
Yes. Is it possible to open that source file, and set a breakpoint?Piazza
Just a thought. You running VS2010SP1? If so, it could be that .NET 4 SP1's source code is not 'available' yet.Piazza
@Piazza That was why i changed my project to target .NET Framework 3.5 (Update 7). But, no, SP1 has not been applied to my VS2010.Boneset
Interesting. I just tested a console app, and getting the same problems as you. Checking the SymbolCache dir, I can see there is PDB's, but no source code. I swear I had source code a few weeks back...Piazza
I know this issue has been sitting out here for over a year, but there might be some movement. Today I noticed the download links are gone from the Shared Source Initiative. referencesource.microsoft.com/netframework.aspx Not sure if this is a positive or a negative.Pitt
Same issue in Visual Studio 2012!Merat
I was able to configure debugging in VS2010 on Win7x86, but after installing latest updates this feature has stopped working (don't have VS2010 SP1 applied, just Win7 updates including SP1)Ashlan
excellent write up of the issue!Ecliptic
It doesn't work in VS2012 either. It worked for a day, after I configured everything and just stopped working. Two days, dozens of coffes, hundreds of web pages later it just doesn't work. In the same time, sources published by symbolsource.org just do work like a charm.Diplomatics
How is it 2022 and this still doesn't work?Stratus
@NikoO Because Visual Studio is not an integrated development environment, but a host of assorted stove-piped language plugins.Boneset
V
35

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

  1. Identify which dll you want to debug into (e.g. System.Windows.Forms.dll)
  2. 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)
  3. 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
  4. 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.
  5. Go to Control Panel->Programs and Features, and click "View Installed Updates"
  6. Find an update which lists the KB number (you can use the search in the upper right box).
  7. Uninstall that update.
  8. 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.

Vassallo answered 14/9, 2012 at 21:11 Comment(10)
Right, the trick is locating the correct ones to uninstall (since usually you have a lot of them installed, and they do take awhile to uninstall).Vassallo
I cannot uninstall security updates. It is against company policy. Is there a way to get copies of mscorlib.dll (and others) that match the Microsoft Symbols server? My mscorlib.dll is verion 4.0.30319.269 (RTMGDR.030319-2600). Possibly, I could temporarily update GAC with this new DLL and try source stepping.Reimer
It's probably against my company policy as well--I just re-install them after I'm done. I don't think you could just plop in an old version mscorlib.dll independent of the other dlls that should get rolled back with it (in order for it to work properly). Furthermore, temporary updating the GAC with old dlls would essentially be equivalent to temporarily uninstalling the security update.Vassallo
The likely reason Microsoft doesn't release source for security updates is that someone could compare the code changes, understand what the security vulnerability was, and create their own exploits. What Microsoft doesn't realize is that the "source code" is already available using ILSpy or Relfector. So Microsoft, by not releasing the source code, is not actually making anyone safer - it's just developers lives more difficult.Boneset
@IanBoyd I doubt that's MS's motivation. I'd assume their workflow simply doesn't support updating source PDB's for debugging. Their primarily concerned with closing security holes.Morez
Sounds ridiculously silly but in the same time works ridiculously effective!Burkett
I uninstalled two updates (KB2805226 and KB2750147‎) that made System.Web.dll version look like this: built by: ...RTMGDR. Now the version looks like this: 4.0.30319.17929 built by: FX45RTMREL. But still, I cannot debug through the source code :(Discernment
@Shedal, Just to be sure: you still need to do all (most) of the other steps listed in the question.Vassallo
@MattSmith Yes, I've tried everything from the question. Right now VS has source stepping enabled and source server enabled and symbol servers configured, even with additional servers (Symbol Source, although I can see in the Modules window it actually loads symbols from the MS servers). I uninstalled two updates, which reverted the dll version to built by: FX45RTMREL (BTW, it's not just RTMREL, there's some prefix there). I still get "no source available" message when I try to step in or hit a breakpoint in the System.Web.dll. I then uninstalled all .NET Framework updates. Didn't help.Discernment
@Shedal, Ah, okay. I just realized that I believe that version number is for .NET 4.5 RTM (vs. the .NET 4.0 RTM). Are you using VS2012 or VS2010. My recommendation: ask a new question and comment here with a link the new question.Vassallo
H
6

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

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

Helios answered 16/7, 2012 at 17:0 Comment(0)
P
4

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. :(

Piazza answered 17/11, 2011 at 6:24 Comment(4)
Well that would be very interesting if my exact steps should work (but don't), will work (in the future), and do work (but not today). It would also be extraordinarily frustrating, as i spent 11 hours on the problem.Boneset
msdl.microsoft.com appears to be Microsoft Symbol ServerHelios
and it's broken againCrump
Does not seem to be a "temporary server issue", 7 years later and the links are still dead.Dedicated
C
1

For now it is not working if you have SP1 installed. Here are some comment about problem form MS: http://social.msdn.microsoft.com/Forums/en-US/refsourceserver/thread/41388c7b-582b-4e3f-8178-3d38a3c99639

Corpsman answered 5/3, 2012 at 11:0 Comment(0)
K
1

In my case, I was debugging an old .NET 2.0 WinForms application and I got the "Source Not Available" message. I tried all the recommended settings.

Ultimately, I rebuilt the app to temporarily target .NET 4.5 and was able to get the source stepping to work. Perhaps my app was just too old for source stepping. Kind of defeats the purpose, I know, but for quick and dirty testing it works. The bug I have is still present in .NET 4.5. :)

Target Framework

Katinka answered 3/11, 2018 at 2:19 Comment(0)
A
0

You can find the reference source here, available for download:

.NET Framework 4.0 Reference source

The sources for WCF, WF, and even the 4.5 Beta / RC and many more can be found there, too:

Microsoft Referencesource NetFramework

Adermin answered 16/7, 2012 at 17:8 Comment(1)
The source code is useless without the symbols. Unless you like searching for a specific piece of code ;pPiazza
L
0

Using dotPeek as the symbol server worked for me. (4.6.2 framework) (I did everything mentioned in this thread and nothing worked, security updates not found...etc)

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

JetBrains dotPeek decompiles your actual .NET DLLs, then hosts a symbol server that you download symbols from in Visual Studio. After a pretty slow download, then a restart of VS, I was able to breakpoint and step into the code.

Lampoon answered 15/9, 2022 at 21:38 Comment(0)
S
-1

Here are the official instructions https://referencesource.microsoft.com/setup.html

Configure Visual Studio 2013 for debugging .NET framework

In order to configure Visual Studio 2013 do the following in the Tools -> Options -> Debugging -> General menu:

  • Disable just my code
  • Disable step over properties and operators
  • Disable require source files to exactly match the original version
  • Enable .NET framework source stepping
  • Enable source server support

enter image description here

Spokeswoman answered 27/10, 2016 at 14:4 Comment(0)
I
-2

if you want to debug open source code (such as nuget package), you can add this url to your symbol server list

http://srv.symbolsource.org/pdb/Public

http://www.symbolsource.org/Public/Home/VisualStudio

Inhibitor answered 11/4, 2013 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.