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

查看:24
本文介绍了显示嵌入在 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.

问题是,如果我尝试在我的 windows 窗体应用程序中设置 ReportViewer 控件的 ReportEmbeddedResource 属性,它将在 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天全站免登陆