我真的不知道该怎么做。我创建了一个通用类来为我的应用程序打开报告。这些报告包含在另一个 DLL 中,但该 DLL 并未作为嵌入式资源引用。
如果我引用 DLL,我可以这样做:
Viewer.LocalReport.ReportEmbeddedResource = "SomeLibrary.ReportName.rdlc";
但是,由于我没有引用 DLL,我认为我必须通过反射获取报告。这就是我卡住的地方。我真的不知道该怎么做。
我真的不知道该怎么做。我创建了一个通用类来为我的应用程序打开报告。这些报告包含在另一个 DLL 中,但该 DLL 并未作为嵌入式资源引用。
如果我引用 DLL,我可以这样做:
Viewer.LocalReport.ReportEmbeddedResource = "SomeLibrary.ReportName.rdlc";
但是,由于我没有引用 DLL,我认为我必须通过反射获取报告。这就是我卡住的地方。我真的不知道该怎么做。
我通过阅读 RDLC 并返回 Stream 找到了一种方法。
public void PrepareReport(IAppReport report)
{
Viewer.LocalReport.LoadReportDefinition(report.GetStream());
}
通过一些反思,我能够拉出那个 Stream 对象。
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream streamReport = assembly.GetManifestResourceStream("MyProjectOrAssemblyName.Reports.Report1.rdlc");
reportView1.ProcessingMode = ProcessingMode.Local;
reportView1.LocalReport.LoadReportDefinition(streamReport);