ssrs-2008rdlcrdlreport-viewer2010localreport

RDL vs RDLC woes when using custom code and subreports in a local report


I'm having a rather complicated problem with SSRS.

First off, we are using Local reports. We have to because the data we are using comes from rest services.

Secondly, we have build a custom library for our reports called ReportFunctions that we want to use.

We are using sql server data tools to build the .rdl (Not to be confused with RDLC) and then we copy the file into our VS project. We set build action to Content and Copy If Newer.

This works great for all of our base reports. We can even use the custom library.

Now we want to use some of these base reports as sub reports. Let's call this report "AllReports". It consists of a "SummaryReport" and a "DetailReport".

Summary and Detail are two RDL files that also need to be loaded independently.

In the code for building AllReports, I have this:

reportViewer.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing;

reportViewer.LocalReport.LoadSubreportDefinition("SummaryReport", File.OpenText(Server.MapPath("SummaryReport.rdl")));
reportViewer.LocalReport.LoadSubreportDefinition("DetailReport", File.OpenText(Server.MapPath("DetailReport.rdl")));

private void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
    //Set e.DataSources here depending on e.ReportPath
}

When I run SummaryReport or DetailReport, they work fine. When I run AllReports I get an error:

The subreport 'SummarySubreport' could not be found at the specified location C:\path\to\my\project\Reports\SummaryReport.rdlc. Please verify that the subreport has been published and that the name is correct.

For fun, I switched the extension of the two sub reports to .rdlc Then I get a build error when I compile in visual studio:

Error while loading code module: ‘ReportFunctions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d88351e3d4dffe2f’. Details: Could not load file or assembly 'ReportFunctions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d88351e3d4dffe2f' or one of its dependencies. The system cannot find the file specified.

DetailReport is the one that uses the external library of custom functions.

I cannot place my DLL anywhere on the server except in the bin of the project. I can't stress this enough. I also cannot move to server reports. I have to use local reports.

If I set the build action to None on the RDLC, it works, but when I deploy my RDLC is not published.

Can I get the RDLC to compile? What am I missing to make my report viewer use an RDL instead of an RDLC for my subreports?


Solution

  • After 11 hours of working on this problem, I discovered the build server was assigning revision numbers to all libraries when they were built. So, locally ReportFunctions would be given 1.0.0.0 as the version and everything was cool. Then when it was deployed the build server would do its thing and the reports would break.

    To anyone else having this issue, check the version numbers of the compiled DLL's, especially if you are using a build process.

    Also, to get around the compile issue of the RDLC, we switched the build action to None and we set up the build server to copy any RDLC files over manually once the build succeeds.