Debug Visual Studio or Blend Silverlight / WPF designer load errors?

为君一笑 提交于 2019-12-14 00:52:49

问题


Is there a way to debug Visual Studio or Blend so I can figure out where XAML designer load errors come from in my code?

The stack traces are often useless.

Thanks...


回答1:


Use two VS2010 instances. Load one with your main app probject or a test harness application project and load the other with your controls project. Having built the controls project reference the debug dlls in your other project. Debugging from the VS2010 instance holding the controls project attach to the VS2010 instance holding the test application.

Place your break points as you like.

Now drive the test application instance of VS2010 as you would when building yout controls into an application, when your controls are load their code will execute and you can start stepping the code. You can do a similar thing when working with your controls in Blend just attach to the Blend instance.




回答2:


In VS, first go to Debug->Exceptions and check the box for "Thrown" for CLR Exceptions. This will break into the debugger for exceptions caught by the Blend/VS app. Then do Debug->Attach To Process... and find the instance of Blend or devenv that has your solution open. Once the debugger starts up you can open the XAML file in the designer and debug against it.




回答3:


Here are another two cents. Just make sure that the Options->Debugging->General->Enable Just My Code is unchecked in the instance you are using to attach to the designer's process.




回答4:


I found both answers useful. Just adding my 2 cents - In the VS copy that you're using to attach to the designer, I needed to select the code type manually (Managed, v4.0 in my example) in the Attach To Process dialog to get the desired result. For some reason the default for devenv was Script, T-SQL. Looking at the date of the OP and original answers, it may be that an update to VS caused this change... just speculating.



来源:https://stackoverflow.com/questions/3453173/debug-visual-studio-or-blend-silverlight-wpf-designer-load-errors

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