I am new to Silverlight 2.0 and I am actually trying to deploy the Silverlight as webpart in Sharepoint 2007.
I have done the following Installations:
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 a reference to both Web.Extensions
and Microsoft.Silverlight
dll's:
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);
}
}
I also deployed the same to the Sharepoint site, then I made an entry to the Sharepoint site's web.config
file to include the Silverlight and Web.Extension assembly's like:
<add assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
Then I 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 steps in the configuration?
Thanks in advance.
Upvotes: 0
Views: 1628
Reputation: 267
After following Toms post, alter the webconfig system.web.extensions values from 1.06... to 3.5.0.0 if using .net 3.5
Upvotes: 0
Reputation:
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!
Upvotes: 1
Reputation:
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&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&v=2.0">\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.
Upvotes: 0
Reputation: 25107
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
Upvotes: 0