gpt4 book ai didi

asp.net - 在 Azure 云服务上动态设置 rdlc 文件时出现 ReportViewer 错误

转载 作者:行者123 更新时间:2023-12-02 23:50:53 26 4
gpt4 key购买 nike

好吧,这应该很容易,但是,我不知道发生了什么。我有一个在 Azure 云服务中运行的 ASP.NET Web 应用程序,并且在其中一个 aspx 页面中有一个 ReportViewer。在此页面的代码隐藏中,我使用以下行动态添加 ReportViewer 的设计 .rdlc 文件:

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

当我在本地主机上运行报告时,一切正常,但当我发布到 Azure 云服务时,出现以下错误:

Could not find a part of the path 'F:\sitesroot\0\reports\myReportFile.rdlc'. Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\sitesroot\0\reports\myReportFile.rdlc'.

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

观察结果:我使用 Azure 工具/包 (.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:

  1. Set the "Build Action" as "Content" then use "Report1.rdlc" in LocalReport.ReportPath Property.

  2. 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 解决了问题。

关于asp.net - 在 Azure 云服务上动态设置 rdlc 文件时出现 ReportViewer 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28718036/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com