I have a report that is used by a windows service and a form application. So, I want to put embed the report in a DLL file that can be used by both.
The problem is that if I try to set the ReportEmbeddedResource property of a ReportViewer control in my windows form app, it will search the windows form app for the resource, not the dll file.
e.g.: Code from the windows form app:
rv.LocalReport.ReportEmbeddedResource = "MyReportInMyDLLFile.rdlc"
How can I make the above command look for the embedded resource in my DLL file?
Something like this should do it:
Assembly assembly = Assembly.LoadFrom("Reports.dll");
Stream stream = assembly.GetManifestResourceStream("Reports.MyReport.rdlc");
reportViewer.LocalReport.LoadReportDefinition(stream);
Just use the full namespace of the assembly, then folder names and then the name of the file:
rv.LocalReport.ReportEmbeddedResource =
"My.Assembly.Namespace.Folder1.Folder2.MyReport.rdlc";
Then make sure the report file is set as an embedded resource using the properties pane.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With