我在 RDLC 报告中收到“尚未指定报告‘xxxx.rdlc’的报告定义”

2024-04-12

我创建了一份 rdlc 报告。我的表单上有一个reportViewer。 当我尝试加载报告时,我得到:“尚未指定报告‘xxxx.rdlc’的报告定义”。我无法弄清楚这一点。 我有一个数据表,其中包含报告所需的数据。 我将这个数据表加载回我的数据库,一个名为“FinalReport”的表。 (我这样做的原因是因为 rdlc 需要某种数据源。) 我的报告中有一个表格(表1)。 这是我的代码(在我的表单内,报告查看器所在的位置):

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();

我还将报表连接到数据表,并将报表查看器连接到报表。 我确实看不出问题所在,我用Google搜索了一下。

任何帮助将不胜感激。


导致此问题的原因有多种,有时仅在将同一应用程序发布到IIS。如果相关位置存在报告文件(*.rdlc)并且问题仍然存在,您可以尝试以下方法来修复它:

from MSDN 上的 LocalReport.ReportEmbeddedResource 属性 https://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.localreport.reportembeddedresource.aspx
“……嵌入式报表资源是作为资源存储在调用程序集中的报表定义。如果已设置 ReportPath 属性,则忽略 ReportEmbeddedResource 属性。它还会导致使用 LoadReportDefinition 加载的报告被忽略。”

Change:

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

to:

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

然后改变Build Action财产给Embedded Resource从属性YourReportName.rdlc file.


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我在 RDLC 报告中收到“尚未指定报告‘xxxx.rdlc’的报告定义” 的相关文章

随机推荐