C# ReportViewer:如何使用反射将报表作为嵌入资源加载到另一个程序集中?

C# ReportViewer:如何使用反射将报表作为嵌入资源加载到另一个程序集中?,c#,reflection,embedded-resource,reportviewer2008,C#,Reflection,Embedded Resource,Reportviewer2008,我真的不知道该怎么办。我创建了一个泛型类来打开应用程序的报告。报告包含在另一个DLL中,但该DLL未作为嵌入式资源引用 如果我引用DLL,我只需执行以下操作: Viewer.LocalReport.ReportEmbeddedResource=“SomeLibrary.ReportName.rdlc” 然而,由于我没有引用DLL,我想我必须通过反射来获取报告。这就是我被困的地方。我真的不知道该怎么做。我找到了一种方法,读取RDLC并返回流 public void PrepareReport(IA

我真的不知道该怎么办。我创建了一个泛型类来打开应用程序的报告。报告包含在另一个DLL中,但该DLL未作为嵌入式资源引用

如果我引用DLL,我只需执行以下操作:
Viewer.LocalReport.ReportEmbeddedResource=“SomeLibrary.ReportName.rdlc”


然而,由于我没有引用DLL,我想我必须通过反射来获取报告。这就是我被困的地方。我真的不知道该怎么做。

我找到了一种方法,读取RDLC并返回流

public void PrepareReport(IAppReport report)
{
   Viewer.LocalReport.LoadReportDefinition(report.GetStream());
}

有了一点反射,我就可以拉出那个流对象。

你能粘贴你用来从dllI读取报告的代码吗?我不知道什么是“IAppReport”,这是一个错误的答案,这是正确的解决方案:System.reflection.Assembly=System.reflection.Assembly.GetExecutionGassembly();streamReport=assembly.GetManifestResourceStream(“MyProjectOrAssemblyName.Reports.Report1.rdlc”);reportView1.ProcessingMode=ProcessingMode.Local;reportView1.LocalReport.LoadReportDefinition(streamReport);
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream streamReport = assembly.GetManifestResourceStream("MyProjectOrAssemblyName.Reports.Report1.rdlc");

reportView1.ProcessingMode = ProcessingMode.Local;
reportView1.LocalReport.LoadReportDefinition(streamReport);