Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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...

like image 645
chadbr Avatar asked Aug 10 '10 20:08

chadbr


3 Answers

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.

like image 125
AnthonyWJones Avatar answered Nov 13 '22 13:11

AnthonyWJones


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.

like image 25
John Bowen Avatar answered Nov 13 '22 14:11

John Bowen


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.

like image 1
Mikhail.Gorbulsky Avatar answered Nov 13 '22 14:11

Mikhail.Gorbulsky