c# - 我在 RDLC 报告中得到 "The report definition for report ' xxxx.rdlc' has not been specified"

标签 c# asp.net

我已经创建了一个 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 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.”

改变:

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

到:

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

然后从 YourReportName.rdlc 文件的属性中将 Build Action 属性更改为 Embedded Resource。希望这有助于...


关于c# - 我在 RDLC 报告中得到 "The report definition for report ' xxxx.rdlc' has not been specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8505700/

相关文章:

c# - TDD 和 DDD 入门

c# - 什么是线程退出代码?

c# - 从列表中检索项目

asp.net - 立即调用 C# 函数在文件上传中选择文件

.net - Visual Studio 2003 上的 "Publish"操作在哪里?

c# - 没有代码隐藏的 ASP.Net

asp.net后台线程异常处理

c# - 显示消息对话框的方法

c# - 访问被拒绝 - 尝试从地址栏的句柄获取 url(文本)时

c# - 如何在 Forms.Authentication 和 ReturnUrl 之间插入确认对话框?