Search code examples
rdlcreportviewerreport-viewer2016

Subreport not loaded when using using LoadReportDefinition


When I load the Report Definition on the LocalReport via the LoadReportDefinition-Method, subreports which are embedded within the report will not be loaded anymore.
I get an rsErrorExecutingSubreport saying that the Report Definition of the Report XY could not be loaded. In english, the error text will probably be:

The report definition for report 'XY' has not been specified

When I load the main report over the ReportEmbeddedResource-property, the subreport works just fine.


Solution

  • When loading the RDLC via LoadReportDefinition, the subreport's report definition must be loaded via the LoadSubreportDefinition-method.

    It will take the name of the subreport as a string and the Stream which holds the sub-report as Parameters.