Mysteries of Silverlight Deployment – Error Code 2104 – Could not download the Silverlight application

So I’m trying to open a newly deployed Silverlight site/app in my browser.  I have the latest version of Silverlight, the files are deployed, the security is configured.  Still, one of my Silverlight apps is downloading to the browser properly, the other one, gives me the following error:

Error: Unhandled Error in Silverlight Application
Code:  2104
Category: InitializeError
Message:  Could not download the Silverlight application.  Check web server settings

I checked the web.config.  Nothing different between the site that works and the one that doesn’t.

I checked a bunch of other things.  Nada.

I finally broke down and started a tab-by-tab comparison of the Web Site Properties dialog in IIS Manager.  (IIS 6.0)  On the HTTP Headers tab, everything matched.  Then I clicked on the MIME Types… button, and there was my discrepancy.

In order for IIS 6 to serve up a Silverlight App, you have to add the following MIME Types to the Web App Properties, HTTP Headers tab:

.xaml application/xaml+xml
.xap application/x-silverlight-app
.xbap application/x-ms-xbap

After adding these entries, I had to click OK a couple of times to get back to IIS Manager and save the change.  Then I had to close and re-open my browser because IE likes to cache everything so even a refresh didn’t download the Silverlight app.  Once I re-opened, the Silverlight app loaded, and I was back to debugging.  Yay.

Different versions of Silverlight 3?

Yes! In fact, it turns out that the subtle difference between the four different versions of Silverlight 3 have caused me several hours of frustration.
To see which version you have, go to C:\Program Files\Microsoft Silverlight.  There have been several:

  • Build 3.0.50106.00 Released January 19, 2010
  • Build 3.0.40818.0 Released September 1, 2009
  • Build 3.0.40723.0 Released July 27, 2009
  • Build 3.0.40624.00 Released July 9, 2009

As of 1/28/10, Silverlight 3.0.50106.0 is the current version.
Different bits and pieces, including the Silverlight client install, the Silverlight Developer install, and the Silverlight Toolkit may or may not cause a spontaneous update to your Silverlight installation. The different versions do install side-by-side so it is entirely possible for you to end up with 3 or 4 different sets of Silverlight DLL’s in the Program Files folder.
This also wreaked havoc with my solution build because some developers had incurred the update and some hadn’t. We are firewalled and protected by the network gods so that we cannot access Microsoft Update / Windows Update, so we need to force the update manually by going to:
A) For client only, use the Silverlight download page: Silverlight Runtime
B) For Silverlight Developer Runtime, you’ll need: Silverlight Developer Runtime

Also, as of 1/28/10, the following downloads should be installed as part of your Silverlight development environment:
The Silverlight Tools for VS2008: Silverlight Tools
The Silverlight Toolkit November 2009 from CodePlex: Silverlight Toolkit

For a new install, make sure you install the Silverlight Tools for VS2008 and then the latest Silverlight Developer Runtime.