显示嵌入在DLL文件中的.RDLC报告 [英] Display .RDLC report embedded in a DLL file

查看:118
本文介绍了显示嵌入在DLL文件中的.RDLC报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows服务和表单应用程序使用的报告。因此,我想将报表嵌入一个可以供双方使用的DLL文件中。

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.

问题是,如果我尝试设置ReportViewer的ReportEmbeddedResource属性,控制在我的Windows窗体应用程序中,它将在Windows窗体应用程序中搜索资源,而不是dll文件。

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.

例如:Windows窗体应用程序中的代码:

e.g.: Code from the windows form app:

rv.LocalReport.ReportEmbeddedResource = "MyReportInMyDLLFile.rdlc"

如何使上述命令在DLL文件中查找嵌入式资源?

How can I make the above command look for the embedded resource in my DLL file?

推荐答案

应该执行以下操作:

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

这篇关于显示嵌入在DLL文件中的.RDLC报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆