My name is António Vargas, I'm Create IT’s consultant and i work here since a one year ago. Well this is my first post on the blog, and i will focus to talk about .Net, Sharepoint and Silverlight technologies on the posts. To see more about me please view my linkedin profile.

Today i will talk about Silverlight and Sharepoint 2007 integration. The problem with this integration is if i have a webpart that contains a Silverlight control, my webpart doesn’t appear. And then, How do you use Silverlight controls in the SharePoint site?

You have to ensure that your server environment is configured for SharePoint and Silverlight intregation. To do this, you should do the following:

  1. Put the XAP files into the Sharepoint Site Bin Folder.
  2. Change the MIME type in the IIS (Internet Information Services).
  3. Change the web.config file in your root SharePoint Site.
  4. Ensure that the System.Web.Silverlight dll is in your GAC (Global assembly cache).

 

Put the XAP files into the Sharepoint Site Bin Folder

You must have to put your XAP files into the Bin Folder, but exist other ways to deploy the that i will talk in the next post.

Steps:

  • Add ClientBin Folder that contains XAP files in the Bin Folder.

 

Changing the MIME Type

You should add MIME support for Silverlight applications that you build and deploy to your SharePoint server.

Steps:

  • Click Start, Administrative Tools, and then select Internet Information Services (IIS) Manager.
  • Under Web Sites in the IIS, click on the web application that represents your SharePoint site.
  • Click “MIME Types”, and then click “Open Feature”.
  • In the Mime Type View, click Add, add the file-type extension
    • type .xap as the “File name extension”
    • application/x-silverlight-2 (for Silverlight 2.0) or application/x-silverlight-app (for Silverlight 3.0) as the “MIME Type”.
  • Click OK to add the new MIME type to IIS.

 

Editing the web.config File

By default, the web.config file of your SharePoint Site does not support Silverlight applications.

This is the most hardest Configuration’s step, because it is required to copy some configurations to the web.config file. To simplify that, i found a tool named stsadm.config in the CodePlex, that it will add all of the Silverlight configurations needed to the web.config of the Sharepoint Site.

Steps:

  • Deploy stsadm.config’s solution writing deploy.stsadmwebconfig.cmd in the command prompt.
  • You must use the following Xml configuration file
      1: <ConfigEntries owner="Administrator">

      2: <ConfigEntry>

      3: <Name>add[@verb='GET,HEAD'][@path='ScriptResource.axd'][@validate='false'][@type='System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35']</Name>

      4: <Path>configuration/system.web/httpHandlers</Path>

      5: <Value><![CDATA[<add verb='GET,HEAD' path='ScriptResource.axd' validate='false' type='System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'/>]]></Value>

      6: <ModType>EnsureChildNode</ModType>

      7: </ConfigEntry>

      8: <ConfigEntry>

      9: <Name>add[@name='ScriptModule'][@type='System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35']</Name>

     10: <Path>configuration/system.web/httpModules</Path>

     11: <Value><![CDATA[<add name='ScriptModule' type='System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'/>]]></Value>

     12: <ModType>EnsureChildNode</ModType>

     13: </ConfigEntry>

     14: <ConfigEntry>

     15: <Name>SafeControl[@Assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'][@Namespace='System.Web.UI'][@TypeName='*'][@Safe='True']</Name>

     16: <Path>configuration/SharePoint/SafeControls</Path>

     17: <Value><![CDATA[<SafeControl Assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35' Namespace='System.Web.UI' TypeName='*' Safe='True' />]]></Value>

     18: <ModType>EnsureChildNode</ModType>

     19: </ConfigEntry>

     20: <ConfigEntry>

     21: <Name>SafeControl[@Assembly='System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'][@Namespace='System.Web.UI.SilverlightControls'][@TypeName='*'][@Safe='True'][@AllowRemoteDesigner='True']</Name>

     22: <Path>configuration/SharePoint/SafeControls</Path>

     23: <Value><![CDATA[<SafeControl Assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" Namespace="System.Web.UI.SilverlightControls" TypeName="*" Safe="True" AllowRemoteDesigner="True" />]]></Value>

     24: <ModType>EnsureChildNode</ModType>

     25: </ConfigEntry>

     26: </ConfigEntries>

 

  • Copy the previous xml file to C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\CONFIG.
  • Run the following command in the command prompt (replace the SharePoint Site Url):

stsadm -o webconfig_apply -url http://createsrv:5003 -configfile SilverlightInSharepoint.xml

Add System.Web.Silverlight dll to GAC

This step does make sense for Silverlight 2.0 because the controls in the System.Web.Silverlight assembly were officially deprecated for Silverlight 3.0. If you are using Silverlight 3.0, you don’t need to add System.Web.Silverlight.dll to GAC.

Otherwise, if you are using Silverlight 2.0, you must need to add the assembly to the GAC. This assembly resides in the following path: C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Server.

 

 

Finally, your Silverlight control just appears in the Sharepoint.

LEAVE A REPLY

Please enter your comment!
Please enter your name here