C# – I’m getting “The report definition for report ‘xxxx.rdlc’ has not been specified” in the RDLC report

asp.netc

I've created an rdlc report. I have a reportViewer on my form.
When I try to load the report I get : "The report definition for report 'xxxx.rdlc' has not been specified". I can't figure this out.
I have a datatable with the data I need for the report.
I take this dataTable and I load it back to my database, to a table called "FinalReport". (The reason i'm doing this, is because that rdlc requires some sort of a dataSource.)
I have a table inside my report (table1).
This is my code (inside my form, where the report viewer is located):

this.finalDataReportTableAdapter.Fill(this.nehasitDataSet.FinalDataReport);
localReport.ReportEmbeddedResource = @"Resources\VisibleAssets.rdlc";
//I'm not so sure about the following line, but it's the only line that prevented me from getting an error ("no reportdefinition defined"
using (StreamReader rdlcSR = new StreamReader(@"Resources\VisibleAssets.rdlc"))
{
    localReport.LoadReportDefinition(rdlcSR);

    localReport.Refresh();
}

this.reportViewer.RefreshReport();

I also connected the report to the dataTable and the reportViewer to the report.
I really can't see the problem, and I searched Google for it.

Any help will be highly appreciated.

Best Answer

There are some reasons causing this problem and sometimes the problem might occur only when publishing the same application to IIS. If the report file (*.rdlc) is existed in the related location and the problem still continues, you can try the following methods in order to fix it:

from LocalReport.ReportEmbeddedResource Property on MSDN
“… An embedded report resource is a report definition that has been stored as a resource in the calling assembly. If the ReportPath property has been set, the ReportEmbeddedResource property is ignored. It also causes the report loaded with LoadReportDefinition to be ignored.”

Change:

reportViewer.LocalReport.ReportPath = Server.MapPath("~/Reporting/YourReportName.rdlc");

to:

rw.LocalReport.ReportEmbeddedResource = "YourFullNamespace.Reporting.YourReportName.rdlc";

And then change Build Action property to Embedded Resource from the properties of YourReportName.rdlc file. Hope this helps...


Related Topic