【问题标题】:C# Pull Report out of a DLL and put it in a Report ViewerC# 从 DLL 中提取报告并将其放入报告查看器中
【发布时间】:2012-03-06 03:23:50
【问题描述】:

我的情况是,我正在创建一个 DLL,其中包含我的报告,然后将该 DLL 添加到我的主项目中。我的报告设置为嵌入式资源,在我的主项目中,我正在执行以下操作以将报告设置为 ReportViewer。

Assembly assembly = Assembly.LoadFrom("MyAssembly.dll");
Stream stream = assembly.GetManifestResourceStream("MyAssembly.Reports.MyReport.rdlc");
MyReportViewer.LocalReport.LoadReportDefinition(stream);
MyReportViewer.RefreshReport();

现在,当我这样做时,我知道报告正在加载,因为我可以设置 ReportParameters。如果它根本没有加载,我会抛出一个异常,说明参数不存在或类似的东西。

发生的事情是我的报告将加载所述参数,当我 RefreshReport() 时,我得到了这个。

尚未指定报告定义的来源。

关于为什么会发生这种情况的任何线索?我觉得从 dll 加载报告时可能会遗漏一些东西。但是,当我在互联网上搜索时,似乎这是正确的解决方案。

附带说明,我的 .dll 中有一个表单,我正在调用它并将报告加载到非常好的状态。但是,这是一种不同的情况,因为该表单明确知道该报告的位置。

在这种情况下,我有一个不在 .dll 内的 ReportViewer,我试图将 .dll 内的 .rdlc 加载到不在 dll 内的 ReportViewer 中。

编辑 最重要的是,如果我使用以下代码,我可以在 dll 中看到我需要的文件。

    string[] resources = assembly.GetManifestResourceNames();

> "MyApp.Controls.Reports.MyCustomReport.rdlc"

【问题讨论】:

  • 嗨,您在此期间找到解决方案了吗?

标签: c# dll reporting embedded-resource


【解决方案1】:

程序开头的这段小代码解决了我的问题

 MyReportViewer.Reset();

【讨论】:

  • 这实际上对我也有帮助,我忘了添加它作为答案
猜你喜欢
  • 1970-01-01
  • 2012-02-09
  • 2014-03-08
  • 2017-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多