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 specifie
I was getting the same error but I'm loading my report in a different way. I followed the instruction on MSDN. Except where they reference ReportEmbeddedResource
I, instead, used ReportPath
. When I make that change my report loads.
public partial class ReportViewer : Page
{
private bool _isReportViewerLoaded;
public ReportViewer()
{
InitializeComponent();
_reportViewer.Load += _reportViewer_Load;
}
void _reportViewer_Load(object sender, EventArgs e)
{
if (!_isReportViewerLoaded)
{
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
BossbergDataset dataset = DataAccessConstants.myDataset;
dataset.BeginInit();
reportDataSource1.Name = "DataSet1"; //Name of the report dataset in our .RDLC file
reportDataSource1.Value = dataset.Table1;
this._reportViewer.LocalReport.DataSources.Add(reportDataSource1);
//My testReport.Rdlc has the [Copy to Output Directory] set to [Copy Always]
this._reportViewer.LocalReport.ReportPath = @"Reports/TestReport.rdlc";
dataset.EndInit();
DataAccessConstants.Table1Adapter.Fill(dataset.Table1);
_reportViewer.RefreshReport();
_isReportViewerLoaded = true;
}
}
}
With my XAML being
Also:
Make sure you are copying your report files to your output directory. If you are using syntax like ../../Myreport.rdlc
you are probably not copying to the output directory.
Make sure you are referencing the right version of the ReportViewer
dll. When I went to References > Add Reference... > Assemblies > Extensions and found the report viewer dll it was an old version. I needed to explicitly navigate to
C:\Program Files (x86)\Microsoft Visual Studio 12.0\ReportViewer\Microsoft.ReportViewer.WinForms.dll
To find the latest. If you get it wrong you'll get an error like
The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' which cannot be upgraded.