[英]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: 我做以下事情:
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.
有时设计师会启动一次并缓存值,您需要有一个干净的,非例外的设计师来追踪问题。
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中的断点将被命中。
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相同。
答案在演练:在设计时调试自定义Windows窗体控件 (MSDN)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.