@TessFerrandez
If you have hangs, performance, memory issues, exceptions or crashes in Silverlight applications you can debug them using windbg and sos just like you would if the issues occurred in other .net applications.
The difference is that Silverlight in IE runs a subset of the framework where the main dll is coreclr.dll rather than mscorwks.dll so you can't use the regular 2.0 version of sos.dll that you can find in the framework directory. Instead you can install the Silverlight Developer Runtime from http://www.microsoft.com/silverlight/resources/tools.aspx and the sos.dll for silverlight will be located in the C:\Program Files\Microsoft Silverlight\2.0.30523.8 directory.
To troubleshoot silverlight applications with windbg and sos you would take a memory dump of the IExplore.exe process that acts as the host for your silverlight application. You can do so with either adplus (as shown in my lab series) or with debug diag, just remember that the process should be IExplore.exe rather than w3wp.exe.
Debugging Basics
For demo purposes I just created a very simple silverlight app with a button that had the following code really bad code in the onclick method, which will make the application throw an exception that we just swallow, and then "hang" for 25 seconds.
To debug the app I follow these steps
1. While it is hanging I take a memory dump of the process using
adplus -p <PID for the IExplore.exe process> -hang
2. I open up the dump in windbg and set the symbol path
.sympath SRV*c:\websymbols*http://msdl.microsoft.com/download/symbols .reload
3. I load up sos.dll from the silverlight directory
.load C:\Program Files (x86)\Microsoft Silverlight\2.0.30523.8\sos
And now I can debug as i would debug any other .net application....
Looking at the stacks to see what is executing
Here we can see the sleep method called from TestSLControl.Page.MyButton_Click...
Looking at recent exceptions
StackTraceString: <none> HResult: 80131500 The current thread is unmanaged
... to name a few examples... In essence, most of what you can look at using regular sos is also available in the silverlight sos.
Have fun,
Tess
PingBack from http://hubsfunnywallpaper.cn/?p=1680
My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. The Web Developer Tools Team announced the release of the Dynamic Data Wizard Preview 0806 for VS 2008 SP1 . US ISV Developer Evangelism
Great post Tess: concise and informative.
I'd be most interested in any real world Silverlight problems you've solved/investigated 'using the powers of the debugger' in the future.
Thanks,
Peter
Link Listing - August 21, 2008
Post: Approved at: Aug-24-2008 Intersoft demos Silverlight 2 controls http://www.sdtimes.com/INTERSOFT_DEMOS_SILVERLIGHT_2_CONTROLS
Tess just posted an article on how to debug Silverlight application using sos.dll. If you have been using
DebugDebuggingSilverlightapplicationswithwindbgandsos.dllWebJavaScriptMemoryLeakDetec...
Debug Debugging Silverlight applications with windbg and sos.dll Web JavaScript Memory Leak Detector
Back in August I wrote a post about how to debug these types of issues in silverlight applications. 
Silverlight 2.0 RTW = Production Debugging Silverlight 2.0 Apps Ok, so we all know that Silverlight 2
What if some non-Silverlight component that used mscorwks.dll (a regular .NET component) was loaded into IE? And then a Silverlight app was loaded. Would both mscorwks.dll and coreclr.dll be loaded in the IE process? If so, I guess you could load both versions of sos when looking at a dump (since they have different paths). Is any of this possible?
thanks,
Marc
Yes, all of the above is possible...
In that case you might have to prefix the command with the path !<path>/sos.command to get the command from the right sos loaded or alternatively unload one sos and load the other to avoid confusion about where the commands come from...
if a command is present in multiple loaded extensions, the extension that is last loaded will have presedence (see .chain for loading order and full name of the extensions)
Is this supposed to work by directly attaching to the iexplore.exe process or does it only work by taking a dump? I've some huge memory leaks with my SL2 app (~50 MBs in one transaction) on the client side. I'm trying to investigate the culprit for this.
Thank you.
.NET ASP.NET MVC Beta Source Code Release - Partial Output Caching in ASP.NET MVC - Partial Requests
Doug, you can attach live or take a dump, either one will work.
The reasons for takig a dump would be
a) to be able to look at it on a different machine
b) to be able to continue working with the process while you are debugging
c) to save it if you want to refer back to it
but there is no difference between what you will see live or in a dump for this purpose...