且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Visual Studio 2017中调试.NET 4.6框架源代码?

更新时间:2021-07-22 09:35:15

在此感谢Hans Passant。请注意,此解决方案还会引起其他问题。

Here is the answer, thanks to Hans Passant. Note that this solution raises additional questions.


  1. 确保 https://referencesource.microsoft.com/ 包含您要调试的确切版本。

  1. Ensure https://referencesource.microsoft.com/ contains the exact version you're debugging.

  • How? Reference source specifies ".NET Framework 4.6.2" but a module version is something like: "4.6.1586.0"
  • You may need to uninstall security updates as explained here: How do you enable "Enable .NET Framework source stepping"?

按此处指定的方式配置Visual Studio:
https://referencesource.microsoft.com/setup.html

Configure Visual Studio as specified here: https://referencesource.microsoft.com/setup.html


  • 取消勾选启用我的代码

  • 勾选启用.NET Framework源代码步进(这应该是唯一需要的步骤)

  • 勾选启用源服务器支持

  • 取消勾选要求源文件与原始版本完全匹配

  • Untick "Enable Just My Code"
  • Tick "Enable .NET Framework source stepping" (this should have been the only step needed)
  • Tick "Enable source server support"
  • Untick "Require source files to exactly match the original version"

确认符号已加载到模块窗口中,其中包括源索引。

Confirm symbols are loaded in the Modules window, with source indexing included.


  • 如何确定是否包括源索引?模块窗口未指定PDB是否已剥离源信息。

Microsoft可以通过提供有用的错误消息而不是默默地使失败失败,从而使此过程更加健壮。

Microsoft could make this process a lot more robust by giving helpful error messages instead of silently failing.