Cover

Problem with Silverlight 1.1 Templates

January 16, 2008
No Comments.

Silverlight Logo
I was teaching on the Silverlight Tour today and since the new release of Silverlight 2.0 is around the corner, I decided to do most my demos in Silverlight 1.1 instead of Silverlight 1.0. There were two problems that cropped up during the class.  Luckily my students were patient while we dug deeper to find out why it was acting wonky.  The two issues I found were:

  • Using a MediaElement to load a video, the DownloadProgress always returned 1.0 or 100% no matter what I did.
  • Using the Downloader to download a zip file just simply threw an exception that it couldn’t download the file.

Curious?  In both cases it stemmed from the fact that the 1.1 templates in Visual Studio 2008 are both file based.  When you launch the test.htm page, it lauches it in the browser using the address of the file as a FILE based address (e.g. “d:\workshop\testproject\test.htm”).

The problem is that  the FILE protocol is treated very differently by Silverlight.  When you download a video over a FILE Uri, the progress fires repeatedly but for some reason always reports 100% (I assume its because it already exists on disk). Downloading the .zip file seems to be related to a security limitation of downloading from the local machine.

To fix this, I simply created a quick and dirty ASP.NET web site project and did a Silverlight Link to my Silverlight project…  Luckily, this worked fine.  The difference here is that the ASP.NET project uses the built-in web server to serve up the page so we could really test these concepts over a web server which is closer to reality than the FILE protocol.

I hope that the new templates released for 2.0 don’t use this same technique.