Generation of a simple web-site in the Microsoft Visual Studio 2010 with the use of Silverlight Viewer for Reporting Services 2008


.NET Framework v4
Silverlight v4
Silverlight v4 Software Development Kit (SDK)
Silverlight v4 Developer Tool
Silverlight v4 Toolkit
Microsoft Visual Studio 2010
Microsoft SQL Reporting Services 2008 Sample Reports


The target of the following guide is to demonstrate the basic moments of Silverlight Viewer for Reporting Services 2008 usage. It gives minimum necessary knowledge in order to start working with the component. We will examine step by step the process of generation of web application with the use of Silverlight Viewer for Reporting Services 2008. We will focus on creation and configuration of the service and, finally a deployment of the report viewer component on the application pages. Your application can be configured to use the processing capability of Microsoft SQL Server 2008 Reporting Services server.

Creating Web site using Microsoft SQL 2008/ 2008 R2 Reporting Services report server.

Step 1. Create a new web site

Step 2. Add a new Silverlight project

Make sure that settings are appropriately configured.

Step 3. Add Perpetuumsoft.ReportingServices.Viewer.Server assembly to the project references, (in "Solution Explorer" mode select 'Add Reference' option from the context menu of SampleApplication.Web). This assembly is located in the 'Bin' folder of the Silverlight Viewer for Reporting Services 2008 installation folder.

Step 4. Add a WCF service named ReportService.svc to the WebSite.

Delete unnecessary IReportService.cs from App_code folder. Inherit a new ReportService class from the ReportServiceRemote class for implementation and further capability to change standard behavior. In order to make ASP.Net context available for the service, the service class needs to be marked by a special AspNetCompatibilityRequirements attribute. The ASP.Net context is required for the service to cache document data, if other mechanism of data storage is not implemented.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using PerpetuumSoft.ReportingServices.Viewer.Server;
using System.ServiceModel.Activation;
// NOTE: You can use the "Rename" command on the "Refactor" 
menu to change the class name "ReportService" in code,
svc and config file together.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class ReportService : ReportServiceRemote { }
In the markup of the ReportService.svc you’ll find the following code:

<%@ ServiceHost Language="C#" Debug="true" Service="ReportService"

CodeBehind="~/App_Code/ReportService.cs" %>

Before you start the next step, check to make sure your WebService is configured correctly.

Step 5. Now it’s necessary to setup Microsoft SQL Reporting Services web service. Make the following modification to a web.config file.

a) Add a section description to the 'configSections' element.

allowLocation="true" allowDefinition="Everywhere"/> </configSections>

b) Add a 'PerpetuumSoftServices' section below the 'configSection' element in the web.config file.

      Type="ReportService, App_Code">
        <Credentials Domain="" UserName="" Password=""/>

Remember that for ASP.NET development server, the assembly name will be a little bit different from IIS web server settings.
It will have some unique name like 'App_Code.xrj8ovnh' and it is not really easy to find where this assembly is located in the file system.
We were able to find it in the following directory: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\viewerwebsite\2116d530\c1e337ce\App_Code.xrj8ovnh.dll. That is why we suppose that it would be more convenient to deploy your website on the IIS.

The basic MsReportingServer attributes you'll have to configure at this stage are 'Url' and 'Credentials'. 'Url' attribute is used to specify the path to your Microsoft SQL Reporting Services 2008 web service, while 'Credentials' attribute defines authorization data to access the Reporting Service web service.

c) Set aspNetCompatibilityEnabled attribute to 'true':

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" 

This attribute is also required for Cache mechanism functionality.

Before switching to the next step, check to make sure the SSRS web service is up and running by typing Url in your web browser.

Step 6. It’s necessary to add the report viewer component to the Silverlight application for the report display. Therefore you should add a reference to the PerpetuumSoft.ReportingServices.Viewer.Client assembly, containing ReportViewer (in "Solution Explorer", item Add Reference in context menu of SampleApplication). This assembly is located in the 'Bin' folder of the Silverlight Viewer for Reporting Services installation folder.

Open MainPage.xaml in the markup designer and add 'xml' namespace for the PerpetuumSoft.ReportingServices.Viewer. Client assembly.

Open the MainPage.xaml.cs source code and add the following code:

public partial class MainPage : UserControl
        public MainPage()
            Loaded += new RoutedEventHandler(Page_Loaded);

        void Page_Loaded(object sender, RoutedEventArgs e)
            reportViewer.DebugMode = DebugModeEnum.Full;

             * HtmlPage.IsEnabled is set in false means that 
             * the silverlight application started in Out-Of-Browser mode
             * Unfortunately there no way to set ServiceUrl from outside 
             * application if the application started in Out-Of-Browser mode
          SilverlightInitParamsHelper initParamsHelper = 
               new SilverlightInitParamsHelper(
               reportViewer.ServiceUrl = initParamsHelper.ServiceUrl;
               reportViewer.DebugMode = initParamsHelper.DebugMode;
  reportViewer.ReportName = 
"/AdventureWorks 2008 Sample Reports/Product Line Sales 2008"
; reportViewer.ApplyTemplate(); reportViewer.RenderDocument(); } }

RenderDocument method invocation leads to the rendering of the current report on the server and its display in the Report Viewer.

The following steps should be performed.

Open Default.aspx in 'Markup' mode and add the following code:

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
""> <html xmlns="" > <head runat="server"> <title>SampleApplication</title> <style type="text/css"> html, body { height: 100%; overflow: auto; } body { padding: 0; margin: 0; } #silverlightControlHost { height: 100%; text-align:center; } </style> <script type="text/javascript" src="Silverlight.js"></script> <script type="text/javascript"> function onSilverlightError(sender, args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().Source; } var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; if (errorType == "ImageError" || errorType == "MediaError") { return; } var errMsg = "Unhandled Error in Silverlight
Application "
+ appSource + "\n" ; errMsg += "Code: "+ iErrorCode + " \n"; errMsg += "Category: " + errorType + " \n"; errMsg += "Message: " + args.ErrorMessage + " \n"; if (errorType == "ParserError") { errMsg += "File: " + args.xamlFile + " \n"; errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } else if (errorType == "RuntimeError") { if (args.lineNumber != 0) { errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " +
args.charPosition + " \n"; } errMsg += "MethodName: " + args.methodName + " \n"; } throw new Error(errMsg); } </script> </head> <body> <form id="form1" runat="server" style="height:100%"> <div id="silverlightControlHost"> <object data="data:application/x-silverlight-2,"
="100%" height="100%"> <param name="source" value="ClientBin/SampleApplication.xap"/> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="4.0.50826.0" /> <param name="autoUpgrade" value="true" /> <param name="initParams"
='ServiceUrl=<%= String.Format("http://{0}{1}",
ResolveUrl("~/ReportService.svc")) %>;DebugMode=Full'
/> <a href=""
="text-decoration:none"> <img src=""
="Get Microsoft Silverlight"
style="border-style:none"/> </a> </object><iframe id="_sl_historyFrame"
="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div> </form> </body> </html>

Please pay attention to <param name=”InitParams” ...> element. This element determines parameters for ReportViewer. The ServiceUrl property specifies Url to ReportService, the DebugMode property specifies the exceptions display mode. The values can be either 'Simple' or 'Full'. The Full mode is useful if the ReportViewer errors occur. We recommend using this ServiceUrl definition to avoid a cross-domain exception.

Step 7. Install Microsoft SQL Reporting Services 2008 Xaml Rendering extension.
There are two ways to install rendering extension: by using the PerpetuumSoft.XamlExtension.msi file and a manual one.
Note: The extension should be installed ONLY to Microsoft SQL Reporting Services 2008.

a) The use of installer.

Run PerpetuumSoft.XamlExtension.msi. The installer determines your SQL configurations and offers the list of available Reporting Services instances.

Check/uncheck the instances to install/uninstall Rendering Extension to selected Reporting Services instances and click 'Apply Changes' button.

b) Manual installation.

First, find location of your Microsoft SQL Reporting Services 2008. The default path is C:\Program Files\Microsoft SQL Server\ MSRS10.MSSQLSERVER \Reporting Services\ReportServer. Copy PerpetuumSoft.ReportingServices.Viewer.ExtensionLink.dll and PerpetuumSoft.ReportingServices.XamlRendering.dll assemblies to the C:\Program Files\Microsoft SQL Server\ MSRS10.MSSQLSERVER \Reporting Services\ReportServer\Bin folder. The mentioned libraries can be found in the installation folder of the rendering extension.

Open C:\Program Files\Microsoft SQL Server\ MSRS10.MSSQLSERVER \Reporting Services\ReportServer\ rsreportserver.config file in Notepad.

Find <Render> section and add the following code to it:

<Extension Name="XAML" 

="false" />  
Save the file.

Open C:\Program Files\Microsoft SQL Server\ MSRS10.MSSQLSERVER \Reporting Services\ReportServer\rssrvpolicy.config file in Notepad.
Find <CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing"> section and add
<CodeGroup class="UnionCodeGroup" version="1" Name="PerpetuumSoftExtensionСodeGroup" Description="" PermissionSetName="FullTrust"> <IMembershipCondition class="UrlMembershipCondition" version="1" Url="c:\Program Files\Microsoft SQL Server\ MSRS10.MSSQLSERVER \Reporting Services\ReportServer\bin\ PerpetuumSoft.ReportingServices.XamlRendering.dll " /> </CodeGroup> to it.

Save the file and restart the instance of Reporting Services.


We have examined basic steps and got a simple and quite operable application. As such, we only used a ready-made implementation. It will be enough for the most cases. If a required behavior differs greatly from the one provided by default, you can modify not only a lot of aspects of Silverlight Viewer for Reporting Services 2008 operation, but also customize the appearance of the report viewer.

Add Feedback