Debugging Silverlight Out-Of-Browser Applications

I was watching Joe Stegman’s talk at PDC09 about “Improving and Extending the Silverlight 4 Sandbox” and I learnt something that I felt I really should have known already and had a bit of a “D’oh!” moment but I’m not too proud to share my ignorance.

You probably know this already but…

If you’re working with a Silverlight out-of-browser application project in VS ( 2008 Sp1 or 2010 ) – i.e. if you’ve done at least the following steps;

image

then your application will spring up and you’ll hit your breakpoint. However, if you now take that application out-of-browser;

image

then you’re breakpoint won’t hit because VS thinks you want to debug Silverlight code in the browser and doesn’t realise that you want to debug Silverlight code inside of SLLauncher.exe which provides the hosting for out-of-browser Silverlight apps.

Now, up until seeing Joe’s talk I’ve been getting around this by manually changing my settings to cause the debugger to launch SLLauncher with the right parameters for my SLOOB and asking to debug Silverlight code inside of that process but it turns out that there’s an automatic setting for that already. All you have to do is set the Silverlight project to be the startup project;

image

and then change the debug properties on that Silverlight project;

image

and you’re in business debugging the SLLauncher process rather than IE.

Ok – if you’re thinking “did he not already know that?” then the honest answer is “nope” but I’m glad I do now 🙂