Display .RDLC report embedded in a DLL file

若如初见. 提交于 2019-12-02 17:16:36
gschuager

Something like this should do it:

Assembly assembly = Assembly.LoadFrom("Reports.dll");
Stream stream = assembly.GetManifestResourceStream("Reports.MyReport.rdlc");
reportViewer.LocalReport.LoadReportDefinition(stream);
Dan Higham

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.

Probably the best thing to do would be to get a stream to the RDLC resource from the other assembly, then pass that to the "LoadReportDefinition" method of the Report Viewer control.

Details of how to get a stream from an embedded resource in a different assembly can be found here : Retrieving Resources with the ResourceManager Class

Additionally, you will need to refer to the embedded resource using it's full namespace path.

E.g. if you have an application with a default namespace of TheApp, and you keep a report called "MyReport.rdlc" in a folder called "Reports", the report reference call would be:-

rv.LocalReport.ReportEmbeddedResource = "TheApp.Reports.MyReport.rdlc";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!