Sunday, November 02, 2008

Resolution - Silverlight Initialize Error 2104

If you are working with Sliverlight application (VS2008 and Silverlight on WindowsXP) and getting the error# 2104 as shown in the figure below, then here are some of the trick which will work for you to resolve the issue:



Before trying any major changes in IIS(inetmgr), go to the solution explorer and open ClientBin folder, in which you will see a file created having name of your application and suffixed with a .xap extension, eg- SilverlightApplication.xap.

Now go to your aspx page which is calling the Page.xaml, in most of the cases if unchanged it will be SilverlightAppliacationTestPage.aspx, open this page (Source view) and you will find that source element is set to:
ClientBin/SilverlightApplication.page

If you observe here the file referred is filename.page which is a default setting, whereas the ClientBin folder have filename.xap, so change the extension of file for source element to .xap

It may help you to get rid of the error. If not...

Lets try some IIS setting changes:

1. Content Expiration Setting

By defalut its not enabled, so enable this:

Step-1: Right-click your Web Site, select Properties from the context menu.
Step-2:Go to HTTP Headers tab and click "Enable Content Expiration".
Step-3:Set the content to expire after 1 minute.

2. Let IIS know about MIME Types and File Extensions

To enable a Silverlight application under your IIS, you need to register some MIME types and file extensions so that the browser on the client's system can load the correct handler.

Step-1: Right-click your Web Site, select Properties from the context menu.
Step-2:Go to HTTP Headers tab and click on "File Types" under Mime Map section.

You need to add the following types:
------------------------------------------
Extension ----- MIME Type
------------------------------------------
.xap ----------- application/octet-stream
.xaml ---------- application/xaml+xml
------------------------------------------

3. Change Execute permissions to Scripts Only.

Step-1: Right-click your Web Site and select Properties from the context menu.
Step-2:Select the Directory tab and change "Execute Permissions" to Script only.

Once these settings are done, retry running your app, it will work for you.

1 comment:

  1. Worked perfectly for me; thanks a ton. The IIS settings did the trick.

    ReplyDelete