Integrating the WPF Report Viewer With Report Server
This topic explains how to setup the WPF Report Viewer to work with Telerik Report Server.
Prerequisites
- Installed and running Telerik Report Server
R2 2016 (2.1.16.x) or higher version
. - A valid (enabled) user account - the built-in Guest user account can be used as well.
- In case you are not using Item Templates, add references to all the assemblies listed in the article Requirements For Desktop Viewers Using Remote Report Sources.
Configuring the WPF Report Viewer to work with Report Server
- To create a window and host the report viewer in it, you can either use the item template, as explained in the article How to Add report viewer to a WPF .NET Framework project, or place it yourself through drag-and-drop from the toolbox.
-
As soon as the report viewer is on your form, select it and locate the
ReportEngineConnection
property. Invoke the UI editor by pressing the ellipsis button. The Report Engine Connection dialog should appear: -
The
Reporting engine
combobox provides the following options:-
Embedded
- the reports will be processed and rendered at the local machine that hosts the viewer. This is the default mode in order to preserve backwards compatibility. -
REST Service
- the reports will be processed at the machine that hosts configured and running REST Service instance. -
Report Server
- the reports will be processed and rendered at the machine that hosts configured and running Telerik Report Server instance.
Select Report Server.
-
In Report Server URL textbox enter the address and port (if needed) of the machine that hosts the Report Server instance.
- In Username textbox enter the user account that will be used to access the report or leave it empty if you want to use the built-in Guest account.
- In Password textbox enter the password associated with the account or leave it empty if you want to use the built-in Guest account.
- In the Document timeout textbox you can change the timeout for rendering a document, the default is
100
seconds. - Uncheck the Keep client alive checkbox if you want the client session to expire.
- Click OK when ready. The dialog will close and the resulting connection string will be populated as a value of the ReportEngineConnection property.
-
Locate the ReportSource property. Invoke the UI editor by pressing the New button. The default property editor, provided by Visual Studio, should appear:
When the ReportEngineConnection property has the
Engine
set toReportServer
, the viewer will serialize the report source identifier property (URI
for the supported UriReportSource) and send it to the service resolver. TheReportServer
will try to decompose the identifier using the format{Category}/{ReportName}
and then look for the corresponding category and report name. Select the UriReportSource entry. Confirm by clicking OK.
-
Expand the ReportSource node in Properties window. In the provided Uri textbox enter the category and the name of the report you want to display using the following format:
{Category}/{ReportName}
, as shown below: Build and run your application. If your settings are configured correctly, you should see the report, hosted on your Report Server instance, displayed in the report viewer of your WPF application. If not, check the Troubleshooting section below.
When setting ReportEngineConnection with code, make sure you call the RefreshReport() method or set the ReportSource property afterward, so the connection's new value will be respected.
Troubleshooting
The most common reasons for failure are related with the authentication against Report Server. It is strongly recommended to use a tool like Fiddler or any other web debugger when investigating such a problem.
Problem | Cause |
---|---|
The viewer displays the message:A problem occurred while registering client.
|
Check if the supplied username and password are valid and the user's state is Enabled in Report Server. |
The viewer displays the message:System.OperationCanceledException: *{ReportName}* report cannot be found
|
Make sure the URL specified in the report source report is valid and such a category and report exist in Report Server. |
The viewer displays the message:System.Net.WebException: The remote name could not be resolved: {server name}
|
Make sure that the server specified in the connection string exists and has a valid and running Report Server instance. |