首页 文章

在Azure Cloud 服务上动态设置rdlc文件时出现ReportViewer错误

提问于
浏览
2

好吧,这应该很简单但是,我无法弄清楚最新情况 . 我有一个在Azure Cloud 服务中运行的ASP.NET Web应用程序,在一个aspx页面中有一个ReportViewer . 在这个页面的代码隐藏中,我动态地添加了ReportViewer的设计.rdlc文件:

ReportViewer1.LocalReport.ReportPath = Server.MapPath("reports/myReportFile.rdlc");

当我在localhost上运行报表时,一切正常,但是当我发布到Azure Cloud 服务时,我收到以下错误:

找不到路径'F:\ sitesroot \ 0 \ reports \ myReportFile.rdlc'的一部分 . 异常详细信息:System.IO.DirectoryNotFoundException:找不到路径'F:\ sitesroot \ 0 \ reports \ myReportFile.rdlc'的一部分 .

这应该是显而易见的,对吗?文件路径无效或.rdlc文件不存在 . 我尝试在Visual Studio上更改.rdlc文件属性,设置“复制到输出目录”=“始终复制”,并再次得到完全相同的错误 .

观察:我使用Azure工具/包(.cscfg .cspkg)发布并通过Azure管理门户上传它们 .

关于我接下来应该做什么的任何想法?

1 回答

  • 2

    经过几个小时的研究,我在这里找到了一个解决方案:https://social.msdn.microsoft.com/Forums/azure/en-US/f1eb4502-0549-4130-a0d9-9f9abf66c6ab/how-to-run-reportviewer-in-azure-?forum=windowsazuredevelopment

    对于rdlc文件,默认情况下,“Build Action”是“Embedded Resource”,导致文件嵌入DLL中 . 将“复制到输出目录”设置为“始终复制”会导致Report1.rdlc文件被复制到bin文件夹 . 知道这一点后,有两种方法可以解决此问题:将“构建操作”设置为“内容”,然后在LocalReport.ReportPath属性中使用“Report1.rdlc” . 将“Copy to Output Directory”设置为“Copy always”或“Copy if newer”,然后在LocalReport.ReportPath Property中使用“bin \ Report1.rdlc” . 曾文超

    建议#1解决了这个问题 .

相关问题