New to Telerik Reporting? Download free 30-day trial

Self Hosting the WCF Reporting Service

The Silverlight Report Viewer and its WCF Reporting Service are no longer supported and deployed with the installation of Telerik Reporting. The last release of Telerik Reporting with included Silverlight Report Viewer is R1 2023.

The advantages of a Self-Hosted service:

  • Easy to use: With only a few lines of code you have your service running.
  • Easy to debug:

    Debugging WCF services that are hosted in a self-hosted environment provides a familiar way of debugging, without having to attach to separate applications that activate your service.

  • Easy to deploy.

  • Flexible: You can easily control the lifetime of your services.
  • Supports all bindings and transport.

To create a Telerik self-hosted reporting service follow the steps below

  1. Create a new Windows console application.
  2. Add references to the following System assemblies:

    • System.ServiceModel
    • System.Runtime.Serialization
    • System.Drawing
    • System.Windows.Forms
  3. Add references to the following Telerik Reporting assemblies:

    • Telerik.Reporting
    • Telerik.Reporting.Service
    • Telerik.Reporting.XpsRendering (in case you plan to render reports in XPS format)
  4. The Telerik Reporting WCF Service is represented by the Telerik.Reporting.Service.ReportServiceBase - abstract class that requires a base URI to be used for proper resource resolution. This base URI is usually the well-known address of the report service endpoint:

    class ReportService : Telerik.Reporting.Service.ReportServiceBase
        static readonly Uri baseUri = new Uri("http://localhost:54321/reportservice");
        protected override Uri BaseAddress
            get { return baseUri; }
        protected override string ApplicationPath
                //Make sure that the ApplicationPath property always returns a valid directory path that ends with a slash (/) or a backslash (\)
                return System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\"; // for WinForms applications
                //return HttpContext.Current.Request.PhysicalApplicationPath; // for ASP.NET applications
    <System.Runtime.Serialization.KnownType(GetType(Object()))> _
    Class ReportService
        Inherits Telerik.Reporting.Service.ReportServiceBase
        Shared ReadOnly baseUri As New Uri("http://localhost:54321/reportservice")
        Protected Overrides ReadOnly Property BaseAddress() As Uri
                Return baseUri
            End Get
        End Property
        Protected Overrides ReadOnly Property ApplicationPath As String
                'Make sure that the ApplicationPath property always returns a valid directory path that ends with a slash (/) or a backslash (\)
                Return System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) & "\" ' for WinForms applications
                'Return HttpContext.Current.Request.PhysicalApplicationPath ' for ASP.NET applications
            End Get
        End Property
    End Class
  5. Create a ServiceHost for our ReportService and call its Open method:

    public class ReportServiceBaseSnippets
        public static void Main(string[] args)
            System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(ReportService));
            // Block the Main() method until the user presses a key; then close the host and exit the program
    Public Class ReportServiceBaseSnippets
        Public Shared Sub Main(ByVal args As String())
            Dim host As New System.ServiceModel.ServiceHost(GetType(ReportService))
            ' Block the Main() method until the user presses a key; then close the host and exit the program
        End Sub
    End Class
  6. To configure the service and its endpoints add the next code to the application’s configuration file:

    <?xml version="1.0" encoding="utf-8" ?>
                <service name="ConsoleApplication1.ReportService"
                            <add baseAddress="http://localhost:54321"/>
                    <endpoint address="ReportService"
                            <dns value="localhost" />
                    <endpoint address="ReportService/resources"
                    <endpoint address=""
                    <endpoint address="mex"
                                contract="IMetadataExchange" />
                    <behavior name="ReportServiceBehavior">
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="false" />
                    <behavior name="WebBehavior">
                        <webHttp />
  7. Add a new report Report1 to the project to test the self-hosted report service.

  8. Run the application – the Windows console will appear and when the "Ready…" message appears the service is ready to operate.
  9. To test the self-hosted Telerik Reporting WCF Service we use the Export operation for the Resource Service (Telerik.Reporting.Service.IResourceService). As it is dedicated to be used by HTTP GET request we will use a web browser application as a client. Open any web browser and type the next address:


    This will call the IResourceService. Export operation that will render the report in PDF with no deviceInfo or parameterValues. When completed, a PDF document will be sent back to the browser.

In this article