Vs2017 Source Not Available

13,076

Solution 1

After following the link pointed by @Jack Zhai-MSFT I was finally able to understaand the reasons why the .net framework couldn´t be debugged.

It turned out that the symbols were being downloaded without their respective source, because I was pointing to Microsoft Symbol Server instead of http://referencesource.microsoft.com/symbols

Then, my following attempt was to uncheck the "Microsoft Symbols Server" or to change the order at the Symbols menu. To my surprise, I couldn´t delete it, nor change the order, and, even after it was disabled the symbols were still fetched from there.

Perhaps this is a VS2017 community bug.

What I did next, that actually solved it:

  1. Deleted my symbol cache that had misleading pdbs without source
  2. Enabled just my code flag, disabling “Enable .NET Framework source stepping” and started the app, on debug mode
  3. Paused at a breakpoint in which, at the stack, I had access to the code I wanted to debug
  4. Double clicked such stack, and then hit Load Symbols.
  5. This time around, for some reason, the Microsoft Symbol Server was skipped, and the right pdbs were downloaded

Note that, still, I couldn´t download some "optimized symbols" like system.net.http, but I´ll try to figure that out next

Also, I setup the symbols servers using that as a reference, which helped me to promptly get any third party symbols (Except .net)

https://www.symbolsource.org/Public/Wiki/Using

enter image description here

EDIT:

With the help of dotPeeker I was able to get all the missing pdb files by:

  1. Loading these dlls into dotpeeker (ex: System.Net.Http)
  2. Load one of the source files from that DLL
  3. Hit Generate PDB and store it into the same cache folder as VS2017 uses

PHEW!! What a hassle for something that should have been trivial!

Solution 2

To debug third party source code, you could use the .NET Reflector or dotPeek with VS.

Reference:

Is it possible to actually debug 3rd party code using the source decompiled with dotPeek?

Update:

If you just want to debug the .NET source code, see: How do I debug .NET 4.6 framework source code in Visual Studio 2017?

Share:
13,076
Luiz Henrique Martins Lins Rol
Author by

Luiz Henrique Martins Lins Rol

Updated on June 04, 2022

Comments

  • Luiz Henrique Martins Lins Rol
    Luiz Henrique Martins Lins Rol almost 2 years

    I´m trying to debug a System.Net.Http.Formating.dll, by clicking at the stack trace:

    System.Net.Http.Formatting.dll!System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStreamAsync.AnonymousMethod__c()
    

    I´ve the "Just my code disabled" and I have the following symbols servers:

    https://nuget.smbsrc.net
    http://localhost:33417/ (dot peek)
    Microsoft Symbol Server
    

    I do have the pdb available, however I get the following error/image.

    How to properly overcome it?

    Why is it such a hassle to debug third party source code at Visual Studio?

    enter image description here

  • Luiz Henrique Martins Lins Rol
    Luiz Henrique Martins Lins Rol over 6 years
    Hi Jack. I tried exactly that very tutorial. I got it working for NewtonSoft.Json, but not for .net assemblies. I even mentioned that briefly on my question (localhost:33417) Not sure why it´s not working.
  • Jack Zhai-MSFT
    Jack Zhai-MSFT over 6 years
    @Luiz Henrique Martins Lins Rol, What library did you really want to debug, third party or the .NET Framework itself? I just edit my answer, if possible, you could refer to it.
  • Luiz Henrique Martins Lins Rol
    Luiz Henrique Martins Lins Rol over 6 years
    .NET indeed. Cool, I´ll have it checked.
  • Luiz Henrique Martins Lins Rol
    Luiz Henrique Martins Lins Rol over 6 years
    I was finally able to load it, using several tweaks. The main reason was due to stackoverflow.com/a/11509020/165622, which I came across your link. However the solution I needed to apply was a bit complex, therefore I´ll create my own answer