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 

http://www.silverlightshow.net/items/Silverlight-and-Sharepoint-2010-getting-started.aspx

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
hi

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

image

Solution Explorer…

image

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.

image

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

namespace CFB.lab.SilverlightWebPartSample.SilverlightApplicaitonWebPart
{
    [ToolboxItemAttribute(false)]
    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='http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0' style='text-decoration:none'>                            "+
             "         <img src='http://go.microsoft.com/fwlink/?LinkId=161376' alt='Get Microsoft Silverlight' style='border-style:none'/>       "+
            "     </a>       "+
            "   </object>              ";                                                                                                          

            writer.Write(x);
            base.Render(writer);

        }
    }
}

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…

image

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='http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0' style='text-decoration:none'>                ""     <img src='http://go.microsoft.com/fwlink/?LinkId=161376' 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

image

Hope this is of some help, happy coding :)

refer

http://dotnet-mcts.jecaestevez.com/2011/04/deploy-silverlight-application-using.html

http://chrisforbesblogs.net/2010/08/11/deploying-a-silverlight-application-to-sharepoint-2010/

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

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

1. configuring IIS --> http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/

2. Silverlight Plug in versioning --> http://msdn.microsoft.com/en-us/library/cc265156(v=VS.95).aspx

3. Silverlight plugin sizing --> http://msdn.microsoft.com/en-us/library/cc189043(v=VS.95).aspx


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

Hope this will help you