SharePoint 2010 and Silverlight Out-Of-Browser with COM Interop – Part IV
Posted by: Pravinkumar Dabade
in Category SharePoint
Abstract: In this article, we will see how to fetch SharePoint lists data in Silverlight Out-Of-Browser applications. We will then deploy this data into an Excel application, using COM Interop, which is a feature of Silverlight 4.0.
In this article, we will see how to fetch SharePoint lists data in Silverlight Out-Of-Browser applications. We will then deploy this data into an Excel application, using COM Interop, which is a feature of Silverlight 4.0.
The first step is to create a Silverlight application which will fetch the data from SharePoint Lists. I have already demonstrated how to fetch the SharePoint list data in Silverlight in, my previous articles – Silverlight Client Object Model in SharePoint 2010 – Part III and Read SharePoint 2010 List in Silverlight using REST – Silverlight with SharePoint 2010 – Part II. For this demonstration I am using the same demo which I have demonstrated in my previous article – Read SharePoint 2010 List in Silverlight using REST – Silverlight with SharePoint 2010 – Part II.
In this demonstration, I have made few changes in the Silverlight application as shown below –
The change is quite simple. I have added one button with the title ‘Write To Excel’. I have also done a couple of changes in the properties of Silverlight project so that my Silverlight application can run out of the browser. The steps are as shown below –
Right click the Silverlight application and go to properties.
Check the check box – ‘Enable running application out of the browser’.
Click on the ‘Out-of-Browser settings’ button and check the check box ‘Require elevated trust when running outside the browser’.
Now add a reference to the ‘Microsoft.CSharp.dll’ file which you can find here – ‘C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client’.
Add some code in the click event of the button ‘Write To Excel’ as shown below –
Now let’s build and deploy the application using SharePoint Solution with Visual Studio 2010. The steps to deploy and test the application using Visual Studio are available in my article – Deploy Silverlight Application using SharePoint 2010 Project
Once you deploy the project, test it as shown in the above article. If you right click the application, you will see a menu to install the Silverlight application. Click on ‘Install application on to this computer’ as shown below –
Once you install the application, it will open the application as a desktop application. Type ‘I’ and click on ‘Search’ button and it will show you the result as shown below –
Now click on the button ‘Write To Excel’ and it will open an Excel workbook with the above data as shown below –
Summary – In this article, we have seen how to fetch the data of SharePoint lists in Silverlight Out-Of-Browser application. We then deployed this data into an Excel application using COM Interop, which is a feature available in Silverlight 4.0.
The entire source code of this article can be downloaded over here