views:

963

answers:

6

Hi dudes,

I am new to this Silverlight 2.0 and i actually trying to deploy the silverlight as webpart in sharepoint 2007.

Installations i have done 1. VS 2008 with SP1 2. Silverlight 2.0 SDK and exe 3. Silverlight Tools for VS 2008 4. MOSS 2007

I have created the sample silverlight application and got the xap file from the bin directory of the solution.

Then i wrote a standard sharepoint webpart with reference to bothe Web.Extnesions and Microsoft.Silverlight dll's... here the code goes

using System; using System.Runtime.InteropServices; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Serialization; using System.Web.UI.SilverlightControls; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.WebPartPages;

namespace SLWeb_Part1 { [Guid("c890f832-05d2-4724-ae25-5f34c827c6c2")] public class SLWeb_Part1 : System.Web.UI.WebControls.WebParts.WebPart { public SLWeb_Part1() { }

    [WebBrowsable(true),
    Personalizable(PersonalizationScope.User),
    WebDescription("Location of the Silverlight XAP package"),
    WebDisplayName("XAP Location")]
    public string XAPSource { get; set; }

    [WebBrowsable(true),
    Personalizable(PersonalizationScope.User),
    WebDescription("Silverlight Controld ID "),
    WebDisplayName("Control ID")]
    public string ControlID { get; set; }


    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
        if (scriptManager == null)
        {
            scriptManager = new ScriptManager();
            this.Controls.Add(scriptManager);
        }
    }

    protected override void CreateChildControls()
    {
        base.CreateChildControls();

        Silverlight sl = new Silverlight();
        sl.Source = XAPSource;
        sl.ID = ControlID;
        sl.Width = new Unit(400);
        sl.Height = new Unit(400);

        this.Controls.Add(sl);
    }
}

deployed the same to the sharepoint site also, then i made an entry to the sharepoint site's web.config file to include the Silverlight and Web.Extension assembly's like

then included application/x-silverlight-app as MIME type for the web application in IIS...

after doing all this... i was able to browse the site as usual, but i couldnt see the SilverLight Component running.... and it is not throwing any error also...

can anybody help me to solve this problem at the earliest, do i miss any step in this configuration???

Thanks in advance Karthick

A: 

You're best starting point would be to read through the Silverlight for SharePoint blueprint from the folks at u2u - http://www.codeplex.com/SL4SP

Slace
A: 

this site talk about Silverlight 2.0 beta version... nw we have silverlight 2.0.exe ready from microsoft... anyway i tried the methods mentioned in this site tooo

A: 

I am trying to do the very same thing and having the very same problem. I've tracked it down to what I believe to be an issue with the ScriptManager.

In a normal ASPX page (where my Silverlight works correctly), the ScriptManager appears to add this to the page:

<script src="/ScriptResource.axd?d=Un3ROg6ZO8lU8fUlhDz-soUWbkyxgh5pk-teueIPxbpft-XX1Z5TrN4P3iF-wiGinTLoxOt5mA420kQULjqoDnUjO5gjwu0sPPlLgxOq-5g1&amp;t=ffffffff888edfb1" type="text/javascript">
</script>
<script type="text/javascript"> 
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

However, the ScriptManager added by my WebPart does not add this code to the page. Thus when the browser reaches the following code that tries to load up the Silverlight, it fails because the Sys object is undefined.

<script type="text/javascript"> 
//<![CDATA[
Sys.UI.Silverlight.Control.createObject('Xaml1_parent', '\u003cobject type="application/x-silverlight-2" id="Xaml1" style="height:100%;width:500px;">\r\n\t\u003cparam name="MinRuntimeVersion" value="2.0.31005.0">\r\n\r\n\t\u003c/param>\u003ca href="http://go2.microsoft.com/fwlink/?LinkID=114576&amp;amp;v=2.0"&gt;\u003cimg src="http://go2.microsoft.com/fwlink/?LinkID=108181" alt="Get Microsoft Silverlight" style="border-width:0;" />\u003c/a>\r\n\u003c/object>');
//]]>
</script>

Hopefully this will at least help move the discussion along.

+1  A: 

I was able to resolve my issue by ensuring that my SharePoint web.config was properly configured for ASP.NET AJAX. It is not set up properly by default. See this site for details on how to do that:

Integrating ASP.NET AJAX with SharePoint

Good luck!

A: 

:(

no... didnt help me.... i jus followed the steps given in this site http://www.u2u.info/Blogs/Karine/Lists/Posts/Post.aspx?ID=40

anybody could help on this issue... i m reaching my deadline date to demonstrate this to my team...
A: 

After following Toms post, alter the webconfig system.web.extensions values from 1.06... to 3.5.0.0 if using .net 3.5

mbowles