无法附加调试 Visual Studio 2017

Unable to Attach Debug Visual Studio 2017

我正在使用 Visual Studio 2017,我正在尝试修复我遇到的错误:

The designer loader did not provide a root component but has not indicated why.

然后当我关闭并重新打开时出现此错误:

Exception of type 'System.ComponentModel.Design.ExceptionCollection' was thrown.

我正在尝试遵循这个答案: System.ComponentModel.Design.ExceptionCollection

  1. 我找不到:

In one instance, goto Debug->Exceptions and enable all the 'Thrown' options to stop at first chance exceptions

所以我转到调试>Windows>异常设置。但我不确定要检查什么,因为没有 'Thrown' 似乎有意义。也许检查一切?

  1. 我无法附加到我尝试执行此操作时丢失的进程:

    在同一实例中,select 调试-> 附加到进程,select devenv.exe。

这是我在Jimi的建议下调试得到的: 1: https://i.stack.imgur.com/VLyJm.png

表单在 运行 时工作正常,只是在设计时有问题。

这是我想出的解决方案。

  1. 我将代码签入 Git 以保存设计文件(您也可以 手动保存在记事本中或保存代码文件进行备份。
  2. 我打开代码文件并将其保持打开状态以解决此错误: 'System.ComponentModel.Design.ExceptionCollection' 类型的异常 被扔了。
  3. 我双击了表格(或者你可以右击代码来 查看设计器)。
  4. 我收到一个新错误,我可以忽略并跳过:设计器加载器 未提供根组件,但未说明原因。
  5. 然后我不得不在表格上移动一些东西,这样表格就会 re-generate 设计师代码。否则错误会不断出现。
  6. 编辑:我不确定把它放在哪里,但它应该可以工作。我仍在尝试解决此问题,但这是我目前所拥有的。我发现一行代码导致了问题。所以我要用这个来 运行 时仅 运行。 Dim designMode As Boolean = (System.ComponentModel.LicenseManager.UsageMode = System.ComponentModel.LicenseUsageMode.Designtime)

砰!已修复 :) 感谢大家的帮助!