Problem with Silverlight 1.1 Templates

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. 

Comments:

Gravatar

actually what you are facing are two probs: 1) cross-protocol isn't allowed in silverlight (i.e., control hosted under FILE, but MediaElement is http) -- you didn't mention where the media file was, but just in case you might be hitting that. the 2) problem is that the downloader will not work with FILE based URLs, period. whether or not is should report 100% (versus an exception or 0%) is debatable, but for security reasons, downloader does not support FILE-based URLs.

Gravatar

As far as the downloader, that makes perfect sense (and sounds like the right behavior...that's what makes the file-based project seem like an odd choice.

I am downloading the video without a protocol, so it should be inheriting mine...and in fact the video loads fine, it just always reports 100%. That's the oddity (difficult to show students how the downloadProgress works if it doesn't show progress ;)

Gravatar

Yeah and this issue still exists in silverlight 2 RCO! What the fuck mircosoft????

Gravatar

I don't think this is a problem as such. Silverlight is meant to use the HTTP protocol, not the FILE protocol so I don't expect it will change for security reasons.


 



 
Save Cancel