从不同的程序集中设置RDLC Report Viewer控件的嵌入式资源报表 [英] Setting Report Embedded Resource of RDLC Report Viewer Control from Different Assembly
问题描述
我正在尝试从程序集中设置Microsoft Report Viewer(MRV)数据,其中我只有MRV的引用。
I am trying to set the Microsoft Report Viewer (MRV) data from an assembly, where I have only the reference of MRV.
如何设置< span style ="font-family:Consolas; font-size:x-small"> LocalReport的ReportEmbeddedResource? LocalReport是只读的。
How can I set ReportEmbeddedResource of LocalReport? LocalReport is readonly.
它需要来自同一程序集的资源。
我的目标是通过设置来自其他程序集的数据在MRV中显示不同的报告。
推荐答案
有点晚了,但我遇到了同样的问题,这样的事情对我有用:
A bit late, but I had the same problem and something like this just worked for me:
MyDatasetTableAdapter ds1 = new MyDatasetTableAdapter();
ReportDataSource rds1 = new ReportDataSource("DataSet1", (DataTable)ds1.GetData());
Assembly assembly = Assembly.GetAssembly(ds1.GetType());
Stream stream = assembly.GetManifestResourceStream("MyOtherNameSpace.MyReport.rdlc");
this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
this.ReportViewer1.LocalReport.LoadReportDefinition(stream);
this.ReportViewer1.LocalReport.DataSources.Add(rds1);
this.ReportViewer1.LocalReport.Refresh();
报表查看程序集引用了另一个包含数据集tableadapter的程序集。 它还包含报告本身。 因此,我可以使用数据集tableadapter来获取正确的程序集,然后从该程序集加载资源
。
The report viewing assembly has a reference to another assembly that contains the the dataset tableadapter. It also contains the report itself. Therefore I can just use the dataset tableadapter to get the right assembly, then load the resource from that assembly.
希望这会有所帮助,尽管我怀疑你修复了这么长时间以前或放弃了!
Hope this helps, although I suspect you fixed this a long time ago or gave up!
Michael
这篇关于从不同的程序集中设置RDLC Report Viewer控件的嵌入式资源报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!