5

I'm not really sure how to go about this. I created a generic class to open reports up for my application. The reports are contained in another DLL that is not referenced as an embedded resource though.

If I reference the DLL I can just do:
Viewer.LocalReport.ReportEmbeddedResource = "SomeLibrary.ReportName.rdlc";

However, since I'm not referencing the DLL I figure I have to get the report via reflection. This is where I'm stuck. I'm really not sure how to go about this.

myermian
  • 31,823
  • 24
  • 123
  • 215

2 Answers2

3

I found a way to do this by reading the RDLC and returning the Stream.

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

With a bit of reflection I am able to pull that Stream object.

myermian
  • 31,823
  • 24
  • 123
  • 215
  • 1
    Can you paste the code you used to read the report as stream from the dll – Smith Nov 09 '15 at 10:05
  • I don´t know what is "IAppReport", that is a bad answer, this is the correct solution: System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); Stream streamReport = assembly.GetManifestResourceStream("MyProjectOrAssemblyName.Reports.Report1.rdlc"); reportView1.ProcessingMode = ProcessingMode.Local; reportView1.LocalReport.LoadReportDefinition(streamReport); – Ejrr1085 Jun 09 '20 at 01:15
1
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream streamReport = assembly.GetManifestResourceStream("MyProjectOrAssemblyName.Reports.Report1.rdlc");

reportView1.ProcessingMode = ProcessingMode.Local;
reportView1.LocalReport.LoadReportDefinition(streamReport);
Ejrr1085
  • 975
  • 2
  • 16
  • 29