在 Azure 云服务上动态设置 rdlc 文件时出现 ReportViewer 错误
ReportViewer error when dynamically setting rdlc file on Azure Cloud Services
好的,这应该很简单,但是我不知道发生了什么。
我有一个 ASP.NET Web 应用程序,它在 Azure 云服务中 运行s,并且在其中一个 aspx 页面中有一个 ReportViewer。在此页面的代码隐藏中,我使用以下行动态添加 ReportViewer 的设计 .rdlc 文件:
ReportViewer1.LocalReport.ReportPath = Server.MapPath("reports/myReportFile.rdlc");
当我 运行 在本地主机上报告时,一切正常,但是当我发布到 Azure 云服务时,出现以下错误:
Could not find a part of the path
'F:\sitesroot[=11=]\reports\myReportFile.rdlc'. Exception Details:
System.IO.DirectoryNotFoundException: Could not find a part of the
path 'F:\sitesroot[=11=]\reports\myReportFile.rdlc'.
这应该是显而易见的,对吧?文件路径无效或 .rdlc 文件不存在。
我尝试更改 Visual Studio 上的 .rdlc 文件属性,设置 "Copy to Output Directory" = "Copy always",但我再次遇到完全相同的错误。
观察:
我使用 Azure Tools/Package (.cscfg + .cspkg) 发布并通过 Azure 管理门户上传它们。
关于我接下来应该做什么有什么想法吗?
经过几个小时的研究,我在这里找到了解决方案:
https://social.msdn.microsoft.com/Forums/azure/en-US/f1eb4502-0549-4130-a0d9-9f9abf66c6ab/how-to-run-reportviewer-in-azure-?forum=windowsazuredevelopment
For rdlc file, by default, the "Build Action" is "Embedded Resource"
causing that the file will be embedded in the DLL. Setting "Copy to
Output Directory" to "Copy always" causes the Report1.rdlc file will
be copied to the bin folder. After knowing this, there are two options
to resolve the issue:
Set the "Build Action" as "Content" then use "Report1.rdlc" in LocalReport.ReportPath Property.
Set "Copy to Output Directory" to "Copy always" or "Copy if newer" then use "bin\Report1.rdlc" in in LocalReport.ReportPath Property.
Wenchao Zeng
建议 #1 解决了问题。
在 windows 表单应用程序的报表查看器中找不到 rdlc
将 "Copy to Output Directory" 设置为 "Copy always" 或 "Copy if newer" 然后在 LocalReport.ReportPath 属性
中使用 "bin\Report1.rdlc"
好的,这应该很简单,但是我不知道发生了什么。 我有一个 ASP.NET Web 应用程序,它在 Azure 云服务中 运行s,并且在其中一个 aspx 页面中有一个 ReportViewer。在此页面的代码隐藏中,我使用以下行动态添加 ReportViewer 的设计 .rdlc 文件:
ReportViewer1.LocalReport.ReportPath = Server.MapPath("reports/myReportFile.rdlc");
当我 运行 在本地主机上报告时,一切正常,但是当我发布到 Azure 云服务时,出现以下错误:
Could not find a part of the path 'F:\sitesroot[=11=]\reports\myReportFile.rdlc'. Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\sitesroot[=11=]\reports\myReportFile.rdlc'.
这应该是显而易见的,对吧?文件路径无效或 .rdlc 文件不存在。 我尝试更改 Visual Studio 上的 .rdlc 文件属性,设置 "Copy to Output Directory" = "Copy always",但我再次遇到完全相同的错误。
观察: 我使用 Azure Tools/Package (.cscfg + .cspkg) 发布并通过 Azure 管理门户上传它们。
关于我接下来应该做什么有什么想法吗?
经过几个小时的研究,我在这里找到了解决方案: https://social.msdn.microsoft.com/Forums/azure/en-US/f1eb4502-0549-4130-a0d9-9f9abf66c6ab/how-to-run-reportviewer-in-azure-?forum=windowsazuredevelopment
For rdlc file, by default, the "Build Action" is "Embedded Resource" causing that the file will be embedded in the DLL. Setting "Copy to Output Directory" to "Copy always" causes the Report1.rdlc file will be copied to the bin folder. After knowing this, there are two options to resolve the issue:
Set the "Build Action" as "Content" then use "Report1.rdlc" in LocalReport.ReportPath Property.
Set "Copy to Output Directory" to "Copy always" or "Copy if newer" then use "bin\Report1.rdlc" in in LocalReport.ReportPath Property.
Wenchao Zeng
建议 #1 解决了问题。
在 windows 表单应用程序的报表查看器中找不到 rdlc 将 "Copy to Output Directory" 设置为 "Copy always" 或 "Copy if newer" 然后在 LocalReport.ReportPath 属性
中使用 "bin\Report1.rdlc"