title: Silverlight WebPart in Sharepoint
body: <p>I am new to Silverlight 2.0 and I am actually trying to deploy the Silverlight as webpart in Sharepoint 2007.</p>
  
  <p>I have done the following Installations:</p>
  
  <ol>
  <li>VS 2008 with SP1</li>
  <li>Silverlight 2.0 SDK and exe</li>
  <li>Silverlight Tools for VS 2008</li>
  <li>MOSS 2007</li>
  </ol>
  
  <p>I have created the sample Silverlight application and got the xap file from the bin directory of the solution.</p>
  
  <p>Then I wrote a standard Sharepoint webpart with a reference to both <code>Web.Extensions</code> and <code>Microsoft.Silverlight</code> dll's:</p>
  
  <pre><code>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);
          }
      }
  </code></pre>
  
  <p>I also deployed the same to the Sharepoint site, then I made an entry to the Sharepoint site's <code>web.config</code> file to include the Silverlight and Web.Extension assembly's like:</p>
  
  <pre><code>&lt;add assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
  </code></pre>
  
  <p>Then I included <code>application/x-silverlight-app</code> as MIME type for the web application in IIS.</p>
  
  <p>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...</p>
  
  <p>Can anybody help me to solve this problem at the earliest?
  Do I miss any steps in the configuration?</p>
  
  <p>Thanks in advance.</p>