How to debug .NET 4.6 source code in Visual Studio 2017?

Here is what I tried:

Created a new console application (.NET Framework) in Visual Studio 2017.

The following code has been added:

static void Main(string[] args) { new Dictionary<int, int>().TryGetValue(3, out int x); //I want to step into TryGetValue() (this is just an example) } 

Configure the options listed here: https://blogs.msdn.microsoft.com/sburke/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code/

Confirmed characters are loaded in the "Modules" window:

mscorlib.dll loaded characters. 4.6.1586.0 built: NETFXREL2

Tried: "Step in (F11)"

Tried: "Step into the concrete" | "System.Collections.Generic.Dictionary.TryGetValue"

Both simply step over the line.

I tried setting up VS using the following data here: http://www.symbolsource.org/Public/Home/VisualStudio

The same result, the debugger goes through the line.

I looked at the answer here: stack overflow

But this version does not seem to be a security update, and a search for "site: support.microsoft.com/kb 4.6.1586.0" yields nothing.

What am I doing wrong?

+17
source share
2 answers

Here is the answer, thanks to Hans Passant. Please note that this decision raises additional questions.

  • Make sure that https://referencesource.microsoft.com/ contains the exact version that you are debugging.

  • Set up Visual Studio as indicated here: https://referencesource.microsoft.com/setup.html

    • Disable "Enable only my code"
    • Check "Enable .NET Framework source step" (this should have been the only step)
    • Check "Enable Source Server Support"
    • Untick "Require source files to match source version"
  • Confirm that the characters are loaded in the Modules window with source indexing enabled.

    • How can you determine if indexing is enabled? The module window does not indicate whether the PDB shared the original information.

Microsoft can make this process much more reliable by providing useful error messages instead of failing silently.

+13
source

Use the character server function in JetBrains dotPeek . After I tried to get the standard functionality to work, it seemed to me charming:

  1. Launch dotPeek and go to Tools> Options ...> Symbol Server.
  2. Make sure All Assemblies is selected, and copy the URL of the local symbol server to the clipboard. Start the dotPeek symbol server by clicking on it in the Tools menu.
  3. In Visual Studio, select Tools> Options ...> Debugging> Symbols and add the dotPeek server URL to the list. Move the dotPeek symbol server as high as possible up the list and clear all other symbol servers in the list ( in particular, Microsoft Symbol Servers and NuGet.org Symbol Server should not be selected ).
  4. Start debugging - when you try to enter the source code of the Framework, you will see that dotPeek does some work of decompiling the assembly for you, and then you get into its source code.

If this does not work, it is possible because Visual Studio previously downloaded the "wrong" characters for the assembly in question from Microsoft / NuGet and uses them instead of the dotPeek request. To verify this, start debugging and find the corresponding assembly in the list of modules (Debug> Windows> Modules) - delete the PDB file in the path specified in the "Symbol File" for this assembly , then restart debugging, and dotPeek should start working.

+5
source

Source: https://habr.com/ru/post/1015612/


All Articles