开发者

Debugging Silverlight and Silverlight Unit Tests

I am having trouble debugging silverlight, and the silverlight unit tests.

Lets first talk about debugging silverlight. My silverlight project has the 'silverlight' debugger checked in the project properties so I don't really understand. Sometimes it will debug OK and I can put breakpoints in my view model classes, and other times not. Is this something that others are finding?

Next is debugging unit tests. I have used the silverlight unit test framework, so the tests run in a browser. How should I debug these tests? I am开发者_运维知识库 writing tests blindly which is OK until things get complicated.

For instance with classic unit testing you can just put in breakpoints. Or else you can use Console.WriteLine. At the very least I need to be able to put something that will write certain debugging information to the web page when the silverlight unit tests are running.

Thanks.


Debugging Silverlight

Debugging in multi-process browsers can be a pain. You often have to manually attach the debugger once you have started debugging as the process started by Visual Studio that it then tries to debug is not the process that the Silverlight plug-in is running under.

Just use Debug-->Attach to process... to do this after you've started the application in debug mode. I have never had failure to debug using this approach.

I also posted here about this multi-process browser Silverlight debugging issue.

NOTE: Multi-process browsers include Chrome, IE8, and Firefox 3.5, although IE8 does something funky to work around the multi-process problem when it's working.

Reporting Feedback

I haven't yet tried this, but here is a useful blog on providing crash handling for Silverlight. It may give you some insight as to how to manipulate your HTML page to provide trace-style logging when unit testing.


For general debugging, when you use 'Attach to process' ensure you have selected 'Silverlight code' in the Attach To field.

For debugging using the silverlight unit test framework, you need to open the project properties of the web project that hosts the unit test page. Choose the 'Web' tab and ensure the Silverlight option is selected in the Debuggers section at the bottom.

Ensure the web project is set as the startup project and the appropriate test page as the start page.

Your breakpoints should then work when you F5 the solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜