Thursday, February 5, 2009

I have been developing a Silverlight application, and i deployed it to a demo server. When i went to test it, the demo gods immediately kicked into gear and i received a script error message instead of seeing my control:

Error: Sys.InvalidOperationException: InitializeError error #2104 in control '[insert my control id here]': Could not download the Silverlight application. Check web server settings

So of course i googled the error message. It turns out this one is very easy to solve, but there is a bit of random rubbish and partial answers floating around out there. It turns out that IIS would not serve the control to the browser because i had not set up the correct MIME types in IIS, so IIS had no idea what the browser was requesting.

The best solution i found was this blog post:

You need to ensure that the website hosting the Silverlight control has the following MIME types registered:

ExtensionMIME type

Realistically you probably only need the xaml and xap entries, but i entered them all and the demo gods smiled once again. Once you have done that, Ctrl-F5 your web page (or just F5 for some other browsers), and you should see your Silverlight control appear.

As per that blog article, i also enabled the content expiration, but i'm not sure of the relevance of that in this particular case (maybe it stops the Silverlight control from being cached?).

keywords: silverlight 2, deploy, error 2104, silverlight mime types