Skip to main content

Patrick Tisseghem's Blog [MVP SharePoint]

Go Search
U2U Blog Center
U2U website
  

The Happy SharePoint Traveller

U2U Blog Center > Patrick Tisseghem's Blog [MVP SharePoint] > Posts > Where to deploy my Silverlight XAP file?
Where to deploy my Silverlight XAP file?

Tomorrow I'll leave for my annual trip to TechEd US again in Orlando. Looking forward to spend time with my buddies Ted and Fitz, and the rest of the gang in the US. Fitz recently joined Nintex and we'll have to catch up on that. From what I read on his blog, Nintex is not all about workflows. This week they'll RTM an interesting reporting layer for SharePoint. Read more here.

Anyway, I am presenting my session first thing Thursday morning. Title is 'Light Up Your SharePoint Web Site with Microsoft Silverlight and AJAX' and I'll highlight techniques for working with Web 2.0 technologies in the SharePoint space. Focus will be on hosting the Silverlight applications, your options to transfer data back and forth, consuming Web Services and WCF services, databinding and more.

I'll show also different techniques for the deployment of the Silverlight XAP file. A XAP file is basically a ZIP file containing the Silverlight solution components such as the compiled XAML and code-behind, an application manifest and possibly one or more assemblies delivering Silverlight controls. There are to me three possible places where you can make the XAP file available and the final choice depends more or less on your scope.

  • Drop the XAP in the ClientBin of your IIS Web Application. This is the most popular approach and also the technique we have used for the BluePrint samples. If you deploy in this location, it means that the Silverlight application can be picked up by any SharePoint code that runs in the site collections and sites hosted on the IIS Web Application. One of the disadvantages with this approach is that it is not directly possible to have the copying of the XAP in the ClientBin operation as part of the manifest of your SharePoint solution delivering the containers for the application (e.g. a Web Part). That is why for the BluePrint, we modified the SharePoint Solution Installer so that this extra step was taking care for.
  • Drop the XAP in the 12 Folder. If the Silverlight application needs to be scoped wider, you have for example a custom field type (which is by default a global deployed SharePoint solution), it is good to deploy in a sub folder of the 12\Template\Layouts or in the 12\Template\ControlTemplates folder. The 12\ISAPI is also a candidate. Deploying here means that you can include all of the deployment steps in your SharePoint Solution.
  • Drop the XAP in a Document Library. This is very often now my preferred choice of place to drop the XAP. You can create one central document library within your site collection (or if you want a more narrow scope, for your site) where to drop the XAP files. Just like with the previous 12 folder location, you can include this deployment also nicely in your Feature that for example makes available the Web Part hosting the Silverlight application.

Say for example that you create a Web Part with the Visual Studio Extensions for WSS 3.0. You can add the XAP file as part of the Feature folder in your Solution Explorer.

image

A Module and a File element in the element manifest file (lines 9-11) can take care of the provisioning of the XAP during the activation of the Feature in an existing document library (e.g. named XAPS).

   1: <Elements Id="c1f27c3d-0fab-46dc-b04d-a070b2713bbd" xmlns="http://schemas.microsoft.com/sharepoint/" >
   2:     
   3:   <Module Name="WebParts" List="113" Url="_catalogs/wp">
   4:       <File Path="HelloDevDays.webpart" Url="HelloDevDays.webpart" Type="GhostableInLibrary" >
   5:           <Property Name="Group" Value="DevDays Web Parts"></Property>
   6:       </File>
   7:   </Module>
   8:  
   9:     <Module Name="XAP" Url="XAPS">
  10:         <File Path="HelloDevDays.xap" Url="HelloDevDays.xap" Type="GhostableInLibrary" />
  11:     </Module>
  12:     
  13: </Elements>

In the Web Part where you create the Silverlight control, you then can point (line 6) to the XAP file using the following code:

   1: protected override void CreateChildControls()
   2: {
   3:     base.CreateChildControls();
   4:  
   5:     Silverlight ctrl = new Silverlight();
   6:     ctrl.Source = SPContext.Current.Site.RootWeb.Url + "/XAPS/HelloDevDays.xap";
   7:     ctrl.ID = "HelloDevDays";
   8:     ctrl.Width = new Unit(400);
   9:     ctrl.Height = new Unit(300);
  10:     ctrl.Version = "2.0";
  11:  
  12:     this.Controls.Add(ctrl);
  13:  
  14: }

As said, a nice and clean way to include all of the Silverlight files in your SharePoint Solution so that no more additional steps need to be taken after the deployment of the Web Part.

It is also very easy to upgrade the XAP files this way. But don't forget to clear your browser cache when you do this. Download the Internet Explorer Developer Toolbar to help you with that.

Comments

Source for SSI modifications?

You mentioned that you modified the Sharepoint Installer to copy the .xap to the ClientBin folder. Have you (or if not, could you) release the source code for that modification? I'd like to modify that to work with SmartParts as well to copy the .ascx files to their folders as part of the installer.
Thanks!
at 9/06/2008 18:03

RE: Source for SSI modifications

I'll see what I can do to have it available here.

Patrick
at 10/06/2008 13:57

Version

When I compile the SL.Sharepoint.HelloSilverlight2 project The version property is not part of the object, but MinimumVersion is. The project is using: System.Web.UI.SilverlightControls.Silverlight. I commented out the version and installed the webpart, but I cannot add it. I get an message box stating: Method not found: 'Void System.Web.UI.SilverlightControls.Silverlight_set_Version(System.String)'.

at 24/06/2008 19:10

RE: Version

I ran in to this problem as well. First, i manually removed the system.web.silverlight.dll from the GAC and added the new one that comes with the beta2 sdk. That then caused a more general error when trying to add the web part. The only way I found around this was to add the system.web.silverlight.dll to the bin directory.
at 2/07/2008 23:14

Debugging Silverlight

I figured out a great way to debug your SL apps.  I used MSBuild to copy the dll, pdb and xap files to the ClientBin folder and then attach to the iExplore process.  Works a treat.
at 21/08/2008 0:59

SharePoint reporting

MAPILab Statistics for SharePoint is another analytics solution. It can be useful for your SharePoint projects: more than 40 customizable interactive reports about SharePoint internal/external portals, great features like full integration with MOSS/WSS/AD, simple implementation and excellent price. http://www.mapilab.com/sharepoint/statistics/
at 15/07/2009 17:26
Captcha

Enter the code shown above: *

(Note: If you cannot read the numbers in the above
image, reload the page to generate a new one.)