45

I am using Visual Studio 2012. I want to Debug .NET Framework source code. I have tried nearly all the options but I am still getting There is source code available for Current Location. Symbols are loaded successfully. I have tried loading Microsoft Symbol Server and tried this url http://referencesource.microsoft.com/symbols. But I am still unable to DEBUG. I have tried these links, http://blogs.msdn.com/b/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx and http://msdn.microsoft.com/en-us/library/cc667410.aspx

Also followed this, http://blogs.msdn.com/b/dotnet/archive/2012/08/15/announcing-the-release-of-net-framework-4-5-rtm-product-and-source-code.aspx

Is anyone able to DEBUG .NET Framework source in VS 2012?

Athari
  • 33,702
  • 16
  • 105
  • 146
Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322
  • 1
    Any change that you build the project in **Release** mode? – Shadow The GPT Wizard Mar 03 '13 at 12:43
  • 5
    Download a free trial of [.NET Reflector](http://www.red-gate.com/products/dotnet-development/reflector/). Install it and make sure it also installs the VS 2012 plugin (VS should be closed). Then follow the instructions in their documentation on how to make it so as that a referenced assembly which is not part of your solution is debuggable as if it were... – Eduard Dumitru Mar 03 '13 at 12:46
  • @ShadowWizard, Nothing. The project is in DEBUG mode. – Imran Qadir Baksh - Baloch Mar 03 '13 at 12:56
  • Sorry, meant "chance". Anyway, if you build simple "hello world" project, can you debug it? If not, something is wrong with the VS installation, try removing and make clean installation again. – Shadow The GPT Wizard Mar 03 '13 at 12:57
  • @ShadowWizard, Is it working with you in VS 2012? – Imran Qadir Baksh - Baloch Mar 03 '13 at 13:02
  • Don't have 2012 just yet (blush) but have enough experience with Debugging in older versions and don't think it changed that much. – Shadow The GPT Wizard Mar 03 '13 at 13:06
  • Did you also checked "**Enable .NET Framework source stepping**"? – Chen Mar 03 '13 at 13:53
  • 1
    Yes I have also followed this, http://blogs.msdn.com/b/dotnet/archive/2012/08/15/announcing-the-release-of-net-framework-4-5-rtm-product-and-source-code.aspx – Imran Qadir Baksh - Baloch Mar 03 '13 at 13:57
  • Must be something wrong with your installation because I've been using 2012 for months and I can debug without issue. Wouldn't make sense to not be able to debug anyway. – Matt Mar 03 '13 at 14:09
  • 1
    @Matt is you are debugging the .NET framework code or just your code – Imran Qadir Baksh - Baloch Mar 03 '13 at 16:01
  • 1
    I've got the same issue, followed the instructions didn't work, played around with all the settings still no luck – Chris Herring Mar 15 '13 at 01:11
  • 1
    @Chris Herring, post owner: same issue here. Can I ask you what data you got and where after installing the reference source? The Readme.txt talks about selecting an arbitrary location, but there wasn't any question. I've found a ton of dlls and xmls in C:\Program Files (x86)\Reference Assemblies\, but no pdbs. So I'm not event sure if the reference source install was successful. – Csaba Toth Apr 16 '13 at 16:26
  • 1
    @ShadowWizard He doesn't have problem with debugging his own source code. But often you have a hundred story tall call stack and majority of it is system/.NET dll. With symbol debugging you can still see the signature of the functions on the call stack (of the "foreign" dlls), but you want to see at least the actual parameter values, and even better: the source code. – Csaba Toth Apr 16 '13 at 16:31
  • @Eduard Dumitru: Reflector is a great tool, and I'd advise it too (actually Visual Studio could do something like Reflector does if source code is not available, it seems that there's no advantage in being in MSIL land, I see x64 assembly). But Reflector it only allows only static analysis of the code. Often to see parameter and variable values on the call stack. – Csaba Toth Apr 16 '13 at 16:36
  • Progress: instead of off-line symbols I had partial success with the reference symbol server: [link](http://social.msdn.microsoft.com/Forums/en-US/refsourceserver/thread/9995fe57-f1fe-44b6-b59a-bb36fdd9c509) – Csaba Toth Apr 16 '13 at 17:24
  • Be sure to wipe out your symbol cache. If you have used the regular Microsoft symbol server, and downloaded pdbs, those are not as rich. They can prevent you from debugging. – Csaba Toth Apr 16 '13 at 17:25
  • try to start visual studio with administrator permissions – Joel May 17 '13 at 19:29
  • @Csaba Toth, not really. Reflector VS plugin allows to decompile assemblies, load decompiled symbols during debugging and get full debugging features for these decompiled assemblies. – user626528 May 20 '13 at 05:27
  • Same issue. I tried the official MSDN setup steps at http://msdn.microsoft.com/en-us/library/vstudio/cc667410(v=vs.110).aspx but it didn't change anything. Tried downloading manually installing the ~200 mb MSI file, and still nothing. Also quite hilarious that 0 of 9 people rated the official setup instructions as helpful. >. – BrainSlugs83 May 31 '13 at 21:34
  • @user626528 Oh, I was in the era of Reflector version 6. Reflector version 8 is brilliant. With the Pro version someone can debug into 3rd party dlls, set breakpoints, etc. Amazing. – Csaba Toth Jun 06 '13 at 17:44

6 Answers6

9

This feature was broken in VS2010 SP1, it might be broken in VS2012 as well. Or Microsoft might release incorrect PDB files for the latest .NET Framework version (this had happened before). Try alternative solutions. I'm using .NET Reflector VSPro - it allows to decompile assemblies, load decompiled symbols during debugging and use full debugging features for these decompiled assemblies.

user626528
  • 13,999
  • 30
  • 78
  • 146
  • 3
    What feature is broken exactly? The incorrectness of the pdbs shouldn't count that much after we uncheck "Require source files to exactly match the original version". In general, the symbol debugging feature and system pdb handling improved 2008->2010->2012. But this thing: debugging into the .NET source is different. – Csaba Toth Apr 16 '13 at 16:28
  • Feature in the name of the question. – user626528 Apr 17 '13 at 12:57
  • 1
    Indeed, the general agreement seems to be that the feature is broken. – David Ebbo May 16 '13 at 16:59
  • 1
    I don't think it's due to the version of Visual Studio, or the fact the feature doesn't work, it's just the only source (or PDB+source information) that was available was for .NET RTM version, and not all the service packs and updates that were released continuously after that holly point in time. @user626528 - do you have "alternative solutions"? – Simon Mourier May 16 '13 at 19:53
  • @Simon Mourier, well, I don't know exact reason. But for me it was working in VS2010 before SP1, and never after. Now I'm using .NET Reflector Pro instead - it allows debugging. – user626528 May 17 '13 at 10:12
  • Reflector isn't as good of an option, as you can't see the comments, and sometimes logical structures get optimized away at compile time, etc, and Reflector can't recreate those. Also Reflector is expensive, and Microsoft supposedly gives us a better option (as I just described) for free. – BrainSlugs83 May 31 '13 at 21:21
  • @BrainSlugs83, what is optimized away - you can't debug, using any tools. Additional benefit of Reflector is that you can debug _any_ assemblies, not only Microsoft's. – user626528 Jun 02 '13 at 05:13
  • @user626528 -- it *used* to work though. It would be better to fix the real issue. Using Reflector is a bad workaround. For example when loops are decompiled, sometimes they come out with random goto statements, or all kinds of bizarre code -- also the comments are missing, all you get is code. Reflector is fine if the code is closed source, but if it's open source (like the .NET framework), it's just stupid. – BrainSlugs83 Jun 04 '13 at 21:30
  • @BrainSlugs83, there is no much choice until MS fixes it. – user626528 Jun 05 '13 at 09:39
  • Assuming it's actually broken and not just some user introduced issue -- I mean, I see websites dedicated to debugging Microsoft's actual source, with VS2012 instructions (I can't make them work), but one would think that it's working somewhere, for someone. – BrainSlugs83 Jun 07 '13 at 03:20
  • @BrainSlugs83, nobody told he was able to make it working so far. – user626528 Jun 07 '13 at 05:28
  • That's not correct. Look at the last answer provided by Grimace of Despair. He says it works for him, and links to a document that explains how to set it up for 2012 (a non MS document, with all kinds of weird steps) -- that being said, I followed those steps and it didn't work for me. Hence, I wonder if there is something wrong with my machine. – BrainSlugs83 Jun 08 '13 at 01:50
  • 1
    @BrainSlugs83, ughm, you can just try to make it working on a fresh VM installation. If you have any luck with this - let us now. – user626528 Jun 09 '13 at 07:37
9

Debugging .NET Framework sources was broken for a long time. See the relevant suggestion on VisualStudio UserVoice Allow developers to step through .NET Framework sources. Good news: it was finally been fixed! See the following blog post from Microsoft:

A new look for .NET Reference Source

In short:

It's currently "beta". Eventually it's going to replace http://referencesource.microsoft.com/. Microsoft also promises to add sources of more assemblies.

Athari
  • 33,702
  • 16
  • 105
  • 146
  • 1
    was it rebroken again? their steps at http://referencesource.microsoft.com/setup.html don't work. – NH. May 03 '17 at 23:11
7

In VS 2008 I was able to debug .Net source, but in VS2012 I've got .NET Reflector (VS extension) installed, so it automatically decompiles and allows to debug any .Net code.

Another open source tool is ilspy.net , it saves the decompiled assembly as C# project and you can use the debugging tools.

There are also debugging tools for Windows, that come as part of SDK, but i haven't tried those: http://msdn.microsoft.com/en-us/windows/hardware/gg463009.aspx

tatigo
  • 2,174
  • 1
  • 26
  • 32
2

Here is a nice post describing how to configure VS symbol server and dotPeek 1.2 to debug decompiled code from VisualStudio: http://blog.jetbrains.com/dotnet/2014/04/09/introducing-dotpeek-1-2-early-access-program If debugging framework or other compiled code is your daily routine I would recommend to reconstruct solution from set of assemblies you use that will save time on symbols loading during debugger attach.

Shkredov S.
  • 2,097
  • 16
  • 8
1

1) PDB files are not up to date. Try to uncheck Tool->Options->Debugging->General->"Require source files to exactly match the original version"

2) You've referenced another of your projects byadding it's dll to your references instead of adding the project as reference. Try to remove the reference add add a new reference to the project from the "Projects" tab

And you can search Google .It's giving more than answers

1

I've had much luck in the past following the procedure as adviced by SymbolSource.

If you combine this with Resharper, you'll be able to CTRL-click your way through the framework.

There's a long history however of MS not publishing the code of all versions of their binaries. That's why often debugging won't work.

Still, Resharper seems a bit more flexible in downloading source code, and if it can't, it'll give you the disassembled source code, yet undebuggable. Note that JetBrains considers the debugging of decompiled sources a critical feature for dotPeek (the decompiler that comes with Re#), so it might be possible within a not too distant future.

Grimace of Despair
  • 3,436
  • 26
  • 38