Debugging System.Threading

此生再无相见时 提交于 2019-12-13 03:32:56

问题


Is it possible to debug System.Threading library?

I have a stack trace that looks somewhat like this:

I have followed all the steps I could see on how to debug .NET libraries.

  • Uncheck 'Enable Just My Code'
  • Check 'Enable .NET Framework source stepping'
  • Check 'Enable Source Sever Support'
  • Check 'Microsoft Symbol Servers' under Symbol file (.pdb) locations

And yet when I try to debug a System.threadin call, I get a file not found page that asks me to Browse and Find the .cs file.

Something like this.

Is it possible to debug System.Threading library? Am I missing any steps?

Edit: I am not sure its a duplicate. For example, the top solution on the other thread asks me to go to referencesource.microsoft.com which does not even contain System.Threading. This is a question specifically for that library. If nothing else, a valid answer for this might be 'It is not possible to debug System.Threadin' or it is possible but use some other method to do so


回答1:


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.



来源:https://stackoverflow.com/questions/57167932/debugging-system-threading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!