Dynamic XAP Loading

Version: 1.0.0

Description

While the overhead of downloading the Silverlight client object model for one Silverlight application may not be very large (approximately 135 KB), when a page or a site makes use of multiple Silverlight applications, and each one includes the client assemblies within the XAP file, it adds up. A better approach is to not include the client object model assemblies inside each application's XAP, but instead to load them dynamically and cache them on the client. Microsoft has packaged up the two Silverlight client object model assemblies into a single XAP file named Microsoft.SharePoint.Client.xap and included it as part of the SharePoint installation. This lab will show how you can programmatically download the assemblies from their location on the server (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin) and have them be cached on the client, thereby improving load time for all Silverlight applications that utilize this approach.

Overview

While the overhead of downloading the Silverlight client object model for one Silverlight application may not be very large (approximately 135 KB), when a page or a site makes use of multiple Silverlight applications, and each one includes the client assemblies within the XAP file, it adds up. A better approach is to not include the client object model assemblies inside each application’s XAP, but instead to load them dynamically and cache them on the client.

Microsoft has packaged up the two Silverlight client object model assemblies into a single XAP file named Microsoft.SharePoint.Client.xap and included it as part of the SharePoint installation. This lab will show how you can programmatically download the assemblies from their location on the server (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin) and have them be cached on the client, thereby improving load time for all Silverlight applications that utilize this approach.

Objectives

This lab will demonstrate how to dynamically download and load the Silverlight client object model assemblies. The example shown here can be adapted to work in any situation.

System Requirements

You must have the following items to complete this lab:

  • 2010 Information Worker Demonstration and Evaluation Virtual Machine
  • Microsoft Visual Studio 2010
  • Silverlight 4
  • Silverlight web part extension for Visual Studio
  • Silverlight 4 Toolkit

Setup

The setup and configuration for this demo involves the following tasks:

  • Task 1 - Start the Microsoft 2010 Information Worker Demonstration and Evaluation Virtual Machine (RTM).
  • Task 2 - Make sure that Silverlight version 4 is installed on the machine
  • Task 3 - Install the Silverlight Web parts Extensions into Visual Studio 2010
  • Task 4 - Make sure that the Silverlight 4 Tools for Visual Studio are installed on the machine
  • Task 5 - Configure the environment for this demo

Task 1 – Starting The Microsoft 2010 Information Worker Demonstration And Evaluation Virtual Machine (RTM)

  1. Follow the instructions in the Virtual Machine Setup Guide.docx file you will find at the following location:

https://www.microsoft.com/downloads/en/details.aspx?FamilyID=751fa0d1-356c-4002-9c60-d539896c66ce&displaylang=en

Task 2 – Making Sure That Silverlight Version 4 Is Installed On The Machine

  1. Download Silverlight 4 from here: https://www.silverlight.net and install

Task 3 – Installing The Silverlight Web Parts Extensions Into Visual Studio 2010

  1. Download the Silverlight and SharePoint VSIX extensions from here: https://code.msdn.microsoft.com/vsixforsp/Release/ProjectReleases.aspx?ReleaseId=4177
  2. Extract the files to your hard drive
  3. Close Visual Studio if it is open
  4. Double-click on the VSIX.SharePoint.Silverlight.vsix file to run the extension installer

Task 4 – Making Sure That The Silverlight 4 Tools For Visual Studio Are Installed On The Machine

  1. Download from here: https://www.microsoft.com/downloads/en/details.aspx?FamilyID=b3deb194-ca86-4fb6-a716-b67c2604a139 and install

Task 5 – Configuring The Environment For This Demo

  1. Run the SetupLab.cmd file from the <INSTALL>\Labs\DynamicXAPLoading\Source\Begin folder to establish the SharePoint environment necessary for this lab.

Exercises

This Hands-On Lab encompasses the following exercises:

  1. Loading the Assemblies Dynamically

Estimated time to complete this lab: 10 minutes.

Starting Materials

This Hands-On Lab includes the following starting materials.

  • Visual Studio solutions. The lab provides the following Visual Studio solutions that you can use as starting point for the exercises.
    • <INSTALL>\Labs\DynamicXAPLoading\Source\Begin\DynamicXAP.sln: This solution contains the initial starting point for all of the exercises in this lab.
    Note:
    Inside each exercise folder, you will find an end folder containing a solution with the completed lab exercise.