【问题标题】:MVC 5 application RDLC Report throws an exception after hosting but works fine with visual studioMVC 5 应用程序 RDLC 报告在托管后引发异常,但在 Visual Studio 中运行良好
【发布时间】:2018-05-05 04:31:28
【问题描述】:

这里是异常和内部异常消息以及堆栈跟踪。当我使用 Visual Studio 运行时,这真的很好。我使用了 ReportViewerForMvc 并通过 Nuget 安装。所以我确实引用了所有.dll。唯一的问题是,一旦我使用 unoeuro 托管,它就无法正常工作。

引发了“System.Web.HttpUnhandledException”类型的异常。

在 System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest(布尔 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest() 在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext 上下文)
在 System.Web.UI.Page.ProcessRequest(HttpContext 上下文) 在 ASP.reportviewerwebform_aspx.ProcessRequest(HttpContext context) 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤, Boolean & completedSynchronously) 本地报告处理过程中出错。

在 Microsoft.Reporting.WebForms.LocalReport.EnsureExecutionSession()
在 Microsoft.Reporting.WebForms.LocalReport.GetParameters() 在 ReportViewerForMvc.ReportViewerExtensions.SetProperties(LocalReport localReport,LocalReport 属性)在 ReportViewerForMvc.ReportViewerExtensions.SetProperties(ReportViewer reportViewer,ReportViewer 属性)在 ReportViewerForMvc.ReportViewerWebForm.BuildReportViewer() 在 ReportViewerForMvc.ReportViewerWebForm.Page_Load(对象发送者, EventArgs e) 在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送者, EventArgs e) 在 System.Web.UI.Control.OnLoad(EventArgs e) 在 System.Web.UI.Control.LoadRecursive() 在 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint)

请帮我解决这个问题。我已经经历了很多线程,但找不到解决方案

【问题讨论】:

  • 可能是 RDLC 报告文件未正确部署到目标环境,或者执行目录更改时未驻留在预期的文件夹(相对路径)中
  • 宾果游戏!!!我忘了检查那个。是的,这就是问题所在。把它作为答案。我会接受!!!如何让它始终发布?我可以通过复制到输出目录来实现它 - 总是复制吗?
  • 添加了我的答案,基于 MSDeploy 的部署,我认为 Copy if newer 在我们的情况下就足够了

标签: c# asp.net-mvc asp.net-mvc-5 rdlc reportviewerformvc


【解决方案1】:

在真正知道原因是什么的情况下,我可以猜测它可能是什么。 RDLC 报告文件(例如 MyReport.rdlc)可能未正确部署到目标环境,或者在执行目录更改时未驻留在预期的文件夹(相对路径)中。

在 Visual Studio 中,确保 Copy to Output Directory 属性设置为 Copy if newer/always,在 IIS 上执行时,文件可能出现在 \bin 目录中,而在本地,它们可能在 bin\Debug 中。

当传入MyReport.rdlc的文件名时,在我们的应用程序中,我们使其可配置并构造如下路径:

var rdlcFullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["ReportingPath"], "MyReport.rdlc");

web.config 文件中,添加路径设置:

<add key="ReportingPath" value="bin\Reports" />

您可以覆盖每个环境的设置以匹配目标结构。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-16
    • 1970-01-01
    • 2012-11-05
    相关资源
    最近更新 更多