Debugging Silverlight code in a SharePoint project

I just banged my head over something totally simple to solve, and as I couldn't find any clues for my problem when searching the Internet, I thought I should blog about it. I hope that way I'll be the last person that just wasted a good couple of hours to finally have the breakpoints in my Silverlight code be hit.
 
Scenario: I have a SharePoint project/solution that dynamically creates & loads a Silverlight control which is a separate project in this solution. I'm using Visual Studio 2008 and C# for both the SharePoint and Silverlight code.
 
As always, debugging my SharePoint project was no problem. However when I tried to enable breakpoints in my Silverlight client code, I just couldn't get the breakpoints to work. I attached to the right iexplore process but nothing happened. I added System.Diagnostics.Debugger.Launch() calls to my code and they would simply be ignored. I just didn't get what was wrong.
 
To cut it short: The problem was that I didn't understand that I had to explicitly set Silverlight as my debugging mode. How? Why? Unlike "normal" Silverlight and Web App solutions that allow you to select "Silverlight Debugging" in the project properties, a SharePoint project has no such setting.
 
So what needs to be done? When you attach to the iexplore process you need to explicitly set the "type of code" you want to debug. I was falsely assuming that the default setting that automatically chooses that type would work, as I was developing in C# all along, but apparently that is two different pairs of shoes, i.e. as this dialog shows:
 
Picture
 
After I selected only Silverlight my break points were hit and the Debugger worked just fine.

Published: Jul-17-09 | 0 Comments | Link to this post