Normal scenario:
We can try upgrading to newest .net 4.8 framework, it works for some situations like these two similar issues How to debug System.Web.dll? and Unable to step into PresentationFramework.
Cause we should ensure https://referencesource.microsoft.com/ contains the exact version we're debugging, most of the time it's better to choose the latest version.
But for this one:
Since upgrading to .net 4.8 seems to not resolve this issue(Maybe something I did wrong in the process?).I choose another direction(using local source
) but it works in my side.
When we're debugging the .net framework source code, apart from the source server, it will also try to find the source in local directory. So we can download the source code
.zip file in our machine and configure the Source File settings for solution
.
1.Go https://referencesource.microsoft.com/ and click the Download button in the upper right corner
2.Download the entire source code of .NET Framework as a .zip file. Since my project targets .net framework 4.8
, so I download the .net 4.8 package.
(We only need to download the appropriate package corresponding to our project, no need to download all of them)
3.Unzip the .zip file which contains source code and move it to an Location I decide to keep the source code, then in VS IDE=>Right-click solution => Properties => Common Properties => Debug Source Files => New Line(Ctrl-Insert) and enter the path of the Source folder(The Source folder in unzipped folder)=>Apply=>OK.
For me, I put the unzipped DotNet48RTM
folder in Documents
folder, so the path I enter in the Debug Source Files setting is C:\Users\xxx\Documents\DotNet48RTM\Source
Then I can step into the System.Threading library after I run a rebuild.
In addition: Make sure you've met all requirements mentioned here. You should disable require source files to exactly match the original version
option and Empty the symbol cache
in Debug=>Options=>Symbols
.