Download custom IReportResolver example (C#)

The Telerik Reporting Service is a WCF service that enables the remote access to the Telerik Reporting Engine (aka ReportProcessor). The Reporting Service acts as a communication interface between the client programs and the ReportProcessor.

The client programs invoke the report rendering from the service using a string report description. Based on the report description the service’s report resolvers try to create an IReportDocument instance needed by the ReportProcessor.

The IReportDocument interface represents a report document. This includes a single Report or ReportBook. The IReportDocument returned by the report resolver will be further handled by the ReportProcessor.

The service includes default report resolvers that are capable to resolve IReportDocument from relative and physical path that points to trdx file (report definition serialized in XML) or from assembly qualified name. This way we cover most of the scenarios. However if you have requirements that are not covered by the default report resolvers, such as retrieving report definitions stored in database or building a report book based on the report description, you can plug into the Telerik Reporting Service report resolving workflow.

The report resolvers implement the IReportResolver interface. This interface has only one method Resolve with a string argument - the report description. In custom resolver implementations you should use that description as you like in order to map it to IReportDocument instance.

If you use the Silverlight report viewer the report description is provided by the ReportViewer.Report property.

  • Web application that targets .NET 3.5 
  • System.ServiceModel.dll assembly 
  • Telerik.Reporting.Service.dll assembly (internal build 
  • Telerik report definition

Even if you use your own IReportResolver implementation you can still fallback to the default IReportResolver implementations as shown in the following walkthrough.

  1. Add to your IReportResolver implementation a constructor with parameter IReportDocument parentResolver. Then use the parentResolver if the custom report resolving mechanism fails. 
    class CustomReportResolverWithFallBack : IReportResolver
        readonly IReportResolver parentResolver;
        public CustomReportResolverWithFallBack(IReportResolver parentResolver)
            this.parentResolver = parentResolver;
        public ReportSource Resolve(string report)
            ReportSource reportDocument = this.CustomReportResolver(report);
            if (null == reportDocument
               && null != this.parentResolver)
                reportDocument = this.parentResolver.Resolve(report);
            return reportDocument;
        public ReportSource CustomReportResolver(string report)
            //TODO implement custom report resolving mechanism
            return null;
  2. Add to Telerik.Reporting.Service subclass the IReportResolver implementations in a chain. Thus the custom one will be executed first, if it fails the second one and so on. 
    namespace CSharp.SilverlightDemo.Web
        using Telerik.Reporting.Service;
        using Telerik.Reporting;
        public class CustomReportService : ReportService
            static readonly IReportResolver resolvers = new CustomReportResolverWithFallBack(
                                    new ReportTypeResolver(
                                      new ReportFileResolver(
                                        new ReportFileResolverWeb(null))));
            public CustomReportService()
                this.ReportResolver = resolvers;

    You can use for fallback the default IReportResolver implementations:
    • ReportTypeResolver - Resolves IReportDocument from assembly qualified name 
    • ReportFileResolver - Resolves IReportDocument from physical path to trdx file
    • ReportFileResolverWeb - Resolves IReportDocument from a relative path to trdx file
  3. Hosting Telerik.Reporting.Service.ReportService subclass in IIS.
    1. Add .svc file (e.g. ReportService.svc) to reference your Telerik.Reporting.Service.ReportService subclass. The file would contain the following line only:
      <%@ServiceHost Service="CSharp.SilverlightDemo.Web.CustomReportService, CSharp.SilverlightDemo.Web" %>
    2. Register the Reporting Service endpoints with service name your Telerik.Reporting.Service.ReportService subclass in the web.config:
      <?xml version="1.0" encoding="utf-8" ?>
                  <service name="CSharp.SilverlightDemo.Web.CustomReportService"
                              <dns value="localhost" />
                              contract="IMetadataExchange" />
                      <behavior name="ReportServiceBehavior">
                          <serviceMetadata httpGetEnabled="true" />
                          <serviceDebug includeExceptionDetailInFaults="false" />
                      <behavior name="WebBehavior">
                          <webHttp />

About the Author

Stefan Tsokev

Stefan’s main interests outside the .NET domain include rock music, playing the guitar and swimming.

Related Posts


Comments are disabled in preview mode.