Jak*_*ake 30 c# reportviewer visual-studio-2010
我的WPF应用程序中有一些RDLC文件.当我发布项目时,报告文件不会被发布,当我尝试使用客户端访问它们时,我会收到错误消息,说明找不到它们.我已经检查了发布文件夹,事实上,它们并不存在.我使用以下代码调用RDLC文件:
Microsoft.Reporting.WinForms.ReportViewer rvReportViewer;
/* ... */
rvReportViewer.LocalReport.ReportPath = string.Format("Reports/{0}.rdlc", ReportName);
Run Code Online (Sandbox Code Playgroud)
我已经尝试将这些构建操作设置为"资源",这是我的静态图像文件,但似乎没有任何区别.
为什么不将报告复制到发布目录?有没有办法强迫这种情况发生,或者我应该以其他方式访问它们?
谢谢!
nos*_*nos 41
I don't know if there's special concerns with RDLC files, but here's the general approach for making sure other files get published.
Right click the file in the solution explorer, select Properties. Set the "Build Action" to "Content", and "Copy to output Directory to "Copy if newer".
Go to the project properties->Publish page. Hit "Application Files Button", check "Show all files". Set the "Publish Status" to "Include (auto)"
File Properties

Application Files

R. *_*urs 36
我一直在使用@nos的答案,但我注意到在发布中,.rdlc文件集被复制到两个地方:
所以,如果我有\ Reports\Report1.rdlc,我会在发布的位置找到:
1. <published folder>\Reports\Report1.rdlc;
2. <published folder>\bin\Reports\Report1.rdlc.
Run Code Online (Sandbox Code Playgroud)
我不是要在第二个位置使用rdlc的副本,实际上,如果我删除它们,仍会生成报告.
我将每个rdlc文件的设置更改为:
Build Action: Content;
Copy to Output Directory: Do not copy.
Run Code Online (Sandbox Code Playgroud)
现在没有任何东西写到第二个位置.
小智 8
对不起,这与"一直复制"或"复制如果更新"无关.实际上我把它设置为"永不复制".通过将"构建操作"从"嵌入式资源"更改为"内容",可以解决此问题.然后,当您构建和发布RLDC文件时,将被复制到正确的位置.
| 归档时间: |
|
| 查看次数: |
30112 次 |
| 最近记录: |