I had been looking for this for quite some time, and I finally found the answer (number 14 on Google with keywords “silverlight downloader debug”). Number 14 is really too low (that’s on page 2, for Pete’s sake). Hopefully this entry will be found more easily.
When you execute a Silverlight 2.0 application in Visual Studio 2008, it gets executed in the “file:” protocol. The page’s URL starts with C:\ (or D: or E:…) or with “file:”. This has the side effect of changing the page’s permissions. And the effect is most unwanted when you use the Downloader: since cross domain and cross protocol access is not allowed by Silverlight security, you cannot use the Downloader in the “file:” protocol!!
Thankfully, it’s not all too difficult to run the Silverlight application in HTTP protocol in Visual Studio.
(by the way, this solution is taken from http://silverlight.net/forums/t/4185.aspx, thanks to Terri Morton)
- Open the solution containing your Silverlight project.
- In the Solution explorer, right-click on the solution and select “Add / New Web Site…”.
- Choose “ASP.NET Web Site”, give a name and a location, and press OK.
- In the new web site, delete the files “Default.aspx” and “Default.aspx.cs”.
- Right click on the new web site, and select “Add Silverlight Link”.
- From the list, select your Silverlight project.
(note: If you have referenced class libraries, they will be added automatically)
- Select “Yes” from the dialog asking you if you want to enable Silverlight debugging.
- Copy the files “TestPage.html”, “TestPage.html.js” and “Silverlight.js” from the original Silverlight project to the new web site project.
- Right click on the Web Site and select “Set as Startup Project”
- If needed, select the file “TestPage.html” in the web site, right click and select “Set as Start Page”.
- Press F5 in Visual Studio.
- If needed, click OK to the option to “Modify the web config file to enable debugging”.
Let’s hope that we will be able to debug Silverlight in HTTP from Visual Studio directly without having to resort to this workaround…
A few words of caution:
- If you modify the file TestPage.html or TestPage.html.js, don’t forget that you now have 2 versions of these files, so you must copy the changes to keep the files consistent!