views:

46

answers:

1

Is it possible to attach Windbg to a Silverlight based application running under internet explorer ( or any other browser)? If its possible, then will I have to attach windbg to the browser and this will get me into that mini CLR under Internet explorer?

+2  A: 

I am not an expert on Silverlight, but you can use WinDbg with Silverlight apps in the browser with some limitations. Also, since you stop the plug-in some browsers such as Chrome will constantly complain about the plug-in not responding.

The first thing you need to do is to make sure you load the correct version of SOS. Silverlight comes with its own version and that's the one you must use. To load the correct version use the CLR module to identify the associated version of SOS. The command is

.loadby sos coreclr

Notice the CLR module is called coreclr in Silverlight.

Use the .chain command to verify that you have the correct version of SOS loaded. If you already have a version of SOS loaded make sure to clear your WinDbg workspace first.

Following that you have access to the regular SOS commands. I've had limited success using some commands such as !clrstack and !dso, but others such as !threads and !dumpheap work as expected.

If you just attach, the !clrstack and !dso commands do not work as expected. However, if you set a breakpoint using !bpmd they will work in the context of the breakpoint. This is probably due to how code is run in a Silverlight app, but as I said I am no expert on Silverlight.

This applies to Silverlight 4.

Tess has a post about debugging Silverlight 2 apps in the browser.

This long post is also worth taking a look at.

Brian Rasmussen