Exercise 2: Create a Silverlight Application and a Framework for Deployment
In this exercise you will add a Silverlight project to an existing solution and create a framework to deploy the Silverlight application to a SharePoint farm.
Task 1 – Adding a new Silverlight Application to the Existing Solution
- Using Visual Studio, open the starter solution from <Install>\Labs\AccessingSPUsingQueryWebServiceSource\Begin\ SilverlightQueryWebService.sln.
- Right-click the SilverlightQueryWebService solution file in the Solution Explorer and select Add New Project.
- Select Silverlight in the left-hand pane and Silverlight Application in the center pane.
Name the project Silverlight.QueryWebService.
Figure 4
Create a new Silverlight application project
- Click OK.
Task 2 – Adding a SharePoint Module to Deploy the Silverlight Xap.
- Right-click on SharePoint.Client.QueryWebService project in Solution Explorer and select Add -> New Item.
- Select the Module project item and name the Module item Silverlight.
- Click Add.
- Right-click on Sample.txt in the Solution Explorer and select Delete to remove the sample file.
- Right-click the Silverlight project item in Solution Explorer and select Properties.
Select Project Output References in the Properties pane.
- Click the ellipse button.
Click Add in in the Project Output References dialog.
Figure 6
Project Output References dialog
- Right-click the Silverlight project item in Solution Explorer and select Add -> Existing Item.
- Set the Project Name property to Silverlight.QueryWebServices.
Set the Deployment Type property to ElementFile. This will include the output of the Silverlight.QueryWebService project in the SharePoint module for deployment.
Figure 7
Project Output References dialog
- Click OK.
- Right-click on the Elements.xml file in the Silverlight module project item and select Open.
- Add Url="SiteAssets" to the Module element
- Add Type="GhostableInLibrary" to the File element.
- Set the Url attribute located in the File element equal to "Silverlight.QueryWebService.xap".
Task 3 – Adding a SharePoint Module to a Custom Aspx Page to Display the Silverlight Application in a Silverlight Web Part.
- Right-click on SharePoint.Client.QueryWebService project in Solution Explorer and select Add -> New Item…
- Select the Module project item and name the Module item CustomPages.
- Click Add.
- Right-click on Sample.txt in the Solution Explorer and select Delete to remove the sample file.
- Right-click on the CustomPages project item and select Add -> Existing Item…
- Select QueryWSDemo.aspx located at <Install>\Labs\AccessingSPUsingQueryWebService\Source\SupportingFiles.
- Right-click on the Element.xml file located in the CustomPages module and select Open.
Replace the Xml in Elements.xml with the Xml included in CustomPagesElements.xml file located at <Install> \Labs\AccessingSPUsingQueryWebService\Source\SupportingFiles.
Exercise 2 Verification
In order to verify that you have correctly performed all steps of exercise 1, proceed as follows:
Verification 1
In this verification, the custom Aspx page will deploy and contain a Silverlight Web Part. The Silverlight application has no user interface and will not display any visible ui.
- Right-click the solution name in Solution Explorer and select Deploy Solution.
- Navigate to https://intranet.contoso.com/queryWSDemo.aspx .
Verify the page loads and contains the Silverlight Query Web Service Web Part.
Figure 8
Silverlight Query Web Service Web Part