简体   繁体   English

如何解决和调试Visual Studio设计模式错误?

[英]How to troubleshoot and debug Visual Studio design mode errors?

Using Windows 7 and Visual Studio 2010, I am writing a C# custom UserControl. 使用Windows 7和Visual Studio 2010,我正在编写一个C#自定义UserControl。 I was coding in code view for weeks and recently when I tried to switch to design mode, Visual Studio hanged, "NOT RESPONDING". 我在代码视图中进行了数周的编码,最近当我尝试切换到设计模式时,Visual Studio被绞死,“没有回应”。 I can wait for an hour, and still nothing happens. 我可以等一个小时,但仍然没有任何反应。 Clicking on the close button it gives the "Do you want to wait, close, restart and send information to Microsoft" dialog. 单击关闭按钮,它会显示“您是否要等待,关闭,重新启动并向Microsoft发送信息”对话框。

Is there a way to (stack)trace the code that the designer is trying to execute? 有没有办法(堆栈)跟踪设计者试图执行的代码? Maybe design-time trace messages or breakpoints? 也许设计时跟踪消息或断点?

For Visual Studio 2010, this answer does the job . 对于Visual Studio 2010, 此答案可以胜任

For Visual Studio 2012 or above, what you need to do is actually debug the Visual Studio Designer process. 对于Visual Studio 2012或更高版本,您需要做的是实际调试Visual Studio Designer进程。 The process you want to debug is called XDesProc.exe 要调试的进程称为XDesProc.exe

在此输入图像描述 .

I do the following: 我做以下事情:

  • Open two instances of Visual Studio both pointing to the same solution 打开两个指向同一解决方案的Visual Studio实例
  • Close all windows in both. 关闭两个窗口。
  • Kill all XDesProc.exe instances in Task Manager 杀死任务管理器中的所有XDesProc.exe实例
  • In Visual studio instance A, open any view (not one that has the exception). 在Visual Studio实例A中,打开任何视图(不是具有异常的视图)。 This will start the XDesProc designer process for Visual Studio Instance A 这将启动Visual Studio实例A的XDesProc设计器进程
  • In Visual Studio instance B, attach to process on XDesProc.exe and set your breakpoints, or, set Break on exceptions 在Visual Studio实例B中,附加到XDesProc.exe上的进程并设置断点,或者设置Break on exceptions
  • In Visual Studio instance A, open the view (that has the exception) 在Visual Studio实例A中,打开视图(具有异常)
  • Visual Studio B should break. Visual Studio B应该破解。

在此输入图像描述

If you missed it, or need to restart the steps, start again from step (2) 'Close all windows' killing XDesProc instances. 如果您错过了它,或者需要重新启动步骤,请从步骤(2)“关闭所有窗口”再次开始查杀XDesProc实例。 Sometimes the designer starts up once and caches values, and you will need to have a clean, non-exception designer to track down the problem. 有时设计师会启动一次并缓存值,您需要有一个干净的,非例外的设计师来追踪问题。

For Visual Studio 2010/2013 对于Visual Studio 2010/2013

You can debug the Visual Studio designer itself! 您可以调试Visual Studio设计器本身! Open a second instance of Visual Studio, use the Tools -> Attach To Process and attach to the first Visual Studio (ie devenv.exe ). 打开Visual Studio的第二个实例,使用Tools -> Attach To Process并附加到第一个Visual Studio(即devenv.exe )。

In Visual Studio instance #2 (the one that you did the Attach To Process in) : Put a breakpoint on your usercontrol's constructor 在Visual Studio实例#2中 (您执行Attach To Process的那个) :在usercontrol的构造函数上放置一个断点

In Visual Studio instance #1 (the original one, that will get stuck) : Open the designer which your usercontrol is in, the breakpoint in VS#2 will get hit. 在Visual Studio实例#1 (原始 实例中 ,将会卡住) :打开您的usercontrol所在的设计器,VS#2中的断点将被命中。

For Visual Studio 2012 对于Visual Studio 2012

The process you want to debug is XDesProc.exe - see Dr. ABT's answer . 您要调试的过程是XDesProc.exe - 请参阅ABT博士的回答 Otherwise the procedure is as for Visual Studio 2010/2013. 否则,该过程与Visual Studio 2010/2013相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我在设计模式下调试某个表单时,Visual Studio崩溃了......“灾难性的失败” - Visual Studio crashes when I debug a project with a certain form open in design mode…“Catastrophic failure” 如何解决 VS2010 构建模式错误 - How to troubleshoot VS2010 Build Mode errors Visual Studio 在调试与发布模式下发布 - Visual Studio publish in debug Vs Release mode Visual Studio 2012不会在调试模式下异常停止 - Visual Studio 2012 not stopping at exception in debug mode 在Visual Studio中以设计模式启用调试 - Enable debugging in design mode in Visual Studio 如何在Visual Studio中调试python - how to debug python in visual studio 在调试模式下启动之前,如何使Visual Studio '17进行构建 - How to make Visual Studio '17 do a build before launching in debug mode 嵌入式Lua“打印”在Visual Studio中无法在调试模式下工作 - Embedded Lua “print” not working in debug mode from Visual Studio Visual Studio 2015 项目不再在调试模式下运行 - Visual Studio 2015 project no longer runs in debug mode 有没有办法在 Visual Studio 中以单线程模式调试多线程应用程序? - Is there a way to debug multithreaded applications in singletreaded mode in Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM