Display .RDLC report embedded in a DLL file

前端 未结 3 1333
谎友^
谎友^ 2021-01-30 12:54

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

3条回答
  •  时光说笑
    2021-01-30 13:45

    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";
    

提交回复
热议问题