In my previous post I have showed you how to display an XtraReport inside a Silverlight application. The assumptions we made last time were that the reports are created by the developer and that they are compiled into the solution. This is not always the case in the real world. Especially when we are working with XtraReports, because it comes with a full end-user report designer.
To dynamically build the reports on the server and to bypass the default registration mechanism of the IReportService (which uses a fully qualified report type name to create report instances) we will override the IReportService.StartBuild. We’ll treat the passed in reportTypeName argument as a file name of the report previously saved by the end-user report designer.

To load the report file, we’ll use the XtraReport.LoadLayout. For example let’s assume that all our reports are saved into a special ~/Reports folder on the server:
public class ReportService : DevExpress.XtraReports.Service.ReportService, IReportService {
const string NoDocumentMsg = "There is no such documentId";
const string NoSessionMsg = "there is no session";
const string NoReportMsg = "There is no such report";
const string filePath = "~/Reports";
public override DevExpress.XtraReports.Service.DataContracts.DocumentId StartBuild(string reportTypeName) {
if (Session == null || User == null)
throw new FaultException(NoSessionMsg);
XtraReport report = new XtraReport();
report.LoadLayout(HttpContext.Current.Server.MapPath(filePath + "//" + reportTypeName));
return ReportServiceContainer.Builder.StartBuild(report, Session, null);
}
}
With this new ReportService implementation, you would now request the reports by the file name like so:
ReportPreviewModel model = new ReportPreviewModel();
model.ReportTypeName = "XtraReport1.repx";
previewControl.Model = model;
model.CreateDocument();
I have uploaded a sample that shows how to open any report file from your Silverlight application. Download it here.
Cheers
Azret