Debugging Silverlight and Silverlight Tests

I am having trouble debugging silverlight, and the module tests are silverlight.

Lets talk about debugging silverlight first. My silverlight project has a "silverlight" debugger checked in the project properties, so I really don't understand. Sometimes it will debug OK, and I can set breakpoints in my view model classes, and in other cases, no. Is this something others find?

Next, debug unit tests. I used the silverlight unit test environment, so the tests run in the browser. How do I debug these tests? I write tests blindly, which is fine until things get complicated.

For example, in classic unit testing, you can simply set breakpoints. Or you can use Console.WriteLine. At the very least, I need to be able to put something that will write certain debugging information to a web page when the silverlight module tests are executed.

Thanks.

+4
source share
2 answers

Silverlight Debugging

Debugging in multiprocessor browsers can be a pain. You often have to manually attach the debugger after you start debugging, because the process that Visual Studio starts and then tries to debug is not the process that the Silverlight plug-in runs on.

Just use Debug-->Attach to process... to do this after starting the application in debug mode. I have never had debugging using this approach.

I also posted here about this issue of the Silverlight layered browser.

NOTE. Multiprocessor browsers include Chrome, IE8, and Firefox 3.5, although IE8 does something funky to get around a multi-process issue when it works.

Feedback reports

I have not tried this yet, but here is a useful blog about providing fail handling for Silverlight. This may give you some insight into how to manipulate your HTML page to provide trace-style logging for unit testing.

+3
source

For general debugging, when you use "Attach to process", make sure you select "Silverlight code" in the Attach To field.

To debug using the silverlight unit test environment, you need to open the project properties of the web project that hosts the unit test page. Select the Web tab and make sure the Silverlight option is selected in the Debuggers section below.

Ensure that the web project is set up as the launch project and the corresponding test page as the start page.

Then your breakpoints should work when you F5 decide.

+3
source

All Articles