SharePoint - Silverlight Webpart: Could not download the silverlight applicato

Asked By selva kumar on 19-Sep-11 01:44 AM

I have developed simple hello World Silverlight Application in silverlight 4 and tried to deploy into Sharepoint Site.

But it showing following error.

Could not download the silverlight applicaton or the silverlight plugin did not load.

I followed following steps:

1.Created Simple Hello world  Silverlight Program . And it is run good in localhost.

2. My .xap size is less than 100kb.

3. I tried to deploy in different method given in

but for all the method I am getting Same Error:

What could be the error.

Its Very Urgent pls help?

smr replied to selva kumar on 19-Sep-11 01:51 AM

refer this example

Creating a web part to display the associated Silverlight application

1. using the existing solution outlined in the previous section select’ Add new item’ within the SharePoint solution. And add a new c# web part (Not a visual web part, this wont work as a sandbox solution anyway) And give it a name. I have been creative here and named it SilverlightApplicationWebPart


Solution Explorer…


2.  We basically want this web part to render out some HTML which will instruct the browser to load the Silverlight application. Luckily the HTML has already been written for us in the supporting Silverlight test web app. Just open up the HTML file and copy the <object> html code.


3. Once you have this code copied open up with webpart code page and add the following code.

namespace CFB.lab.SilverlightWebPartSample.SilverlightApplicaitonWebPart
    public class SilverlightApplicaitonWebPart : WebPart

        protected override void Render(HtmlTextWriter writer)
            string x =                                                                                                                           "+
            "     <param name='source' value='ClientBin/SilverlightApplication.xap'/>                                                            "+
            "     <param name='onError' value='onSilverlightError' />                                                                            "+
            "     <param name='background' value='white' />                                                                                      "+
            "   <object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='100%' height='100%'>                  "+
            "     <param name='minRuntimeVersion' value='4.0.50401.0' />                                                                         "+
            "     <param name='autoUpgrade' value='true' />                                                                                      "+
            "     <a href='' style='text-decoration:none'>                            "+
             "         <img src='' alt='Get Microsoft Silverlight' style='border-style:none'/>       "+
            "     </a>       "+
            "   </object>              ";                                                                                                          



Note : You need to change the first line of the HTML as the silverlight app will no longer exists in the ClientBin. This should now read…

        “   <param name=’source’ value=’SilverlightFile/SilverlightApplication.xap’/>    “

The ‘SilverlightFile’ corresponds to the module name you gave within the SharePoint project.

When you copy the HTML over just highlight the code and do a quick find and replace of the double quotes to single quotes. Then build this out as a string.

If you really want to save time you could use the new multi-line edit in VS2010 just hold the Alt key while selecting the space on the screen where you want to add multiple lines of the same content…


Note: If your Silverlight needs any init parameters you can easily add them here. For example you may require some query string parameters. You can get this from the web part and add dynamically add them to your string. Here is an example of injecting a querystring value

   public class SilverlightApplicaitonWebPart : WebPart    {            protected override void Render(HtmlTextWriter writer)      {        string YOURVALUE = "";        if (Context.Request.QueryString["yourvalue"] != null) YOURVALUE = Context.Request.QueryString["yourvalue"].ToUpper();

        string x =                                                               "+   "   <param name='source' value='ClientBin/SilverlightApplication.xap'/>                                "+   "   <param name='onError' value='onSilverlightError' />                                        "+   "   <param name='background' value='white' />                                            "+        "   <object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='100%' height='100%'>          "+   "   <param name='minRuntimeVersion' value='4.0.50401.0' />                                     "+   "   <param name='autoUpgrade' value='true' />                                            "+        "   <param name='initParams' value='YOURKEY="+YOURVALUE+ "' />" +   "   <a href='' style='text-decoration:none'>                ""     <img src='' alt='Get Microsoft Silverlight' style='border-style:none'/>     "+   "   </a>     "+     "   </object>        ";                                                                                                                                       writer.Write(x);        base.Render(writer);          }    }

4. OK so now you are good to build. Providing you have no build errors, right-click the SharePoint project and select ‘Deploy’

5. To test the web part, edit a page within the SharePoint site and locate the published web part. Once its added to the page it should load up the appropriate silverlight app. My example has gone for an innovative ‘Hello SharePoint from Silverlight’ message. My creativity knows no bounds.

Editing the page – select the published web part to add then click Add…image


Hope this is of some help, happy coding :)


Reena Jain replied to selva kumar on 19-Sep-11 02:04 AM

i am not sure but, may be you can try this out. 

1. configuring IIS -->

2. Silverlight Plug in versioning -->

3. Silverlight plugin sizing -->

Instead of using built-in silverlight webpart deployment in sharepoint 2010, use webpart with toolbox parameter as xap url.

Hope this will help you