【问题标题】:Crystal Report : Load Report Failed after Deployment C# Winforms ApplicationCrystal Report:部署 C# Winforms 应用程序后加载报告失败
【发布时间】:2016-08-01 11:57:24
【问题描述】:

我是 C# winforms 应用程序开发的新手,目前我正在开发一个具有 Crystal Reports 的 winforms 应用程序,并且在开发期间在调试和没有调试模式的情况下工作正常。 但是当我部署它并在客户端 PC 上运行时,它在我尝试打开任何 Crystal Report 时给我一个错误。

它给出报告加载失败的错误-->.

************** Exception Text **************
CrystalDecisions.Shared.CrystalReportsException: Load report failed. ---> System.Runtime.InteropServices.COMException: Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.
   at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
   at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
   at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
   --- End of inner exception stack trace ---
   at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
   at ePos._forms._pos._reports.customerLedgerReport.ShowReport(DataTable dtable)
   at ePos._forms._pos._reports.customerLedgerReport.customerLedgerReport_Load(Object sender, EventArgs e)

请帮助我,将非常感谢您。 :)

【问题讨论】:

  • 感谢您的友好回复。我已经看起来了,但不适合我..

标签: c# .net winforms deployment crystal-reports


【解决方案1】:

这个问题的唯一原因是“应用程序找不到水晶报告(.rpt)”是什么原因。

以下是此错误消息的可能原因。

  • ‘Load()’方法中指定的报表位置无效或
    该位置不存在报告。

    发生这种情况是因为在开发应用程序时,报告位置是从开发机器指定的,但是一旦部署应用程序,位置就会根据 IIS 文件夹结构发生变化。

    检查 .rpt 文件的路径。这样应该就能解决了

    Server.MapPath("~/Reports/InvoiceRegular.rpt");
    

    或者—— 右键单击Rpt文件->选择属性-> 改变了

    • 将操作构建为“内容”。
    • 复制到输出目录为“不复制”。
    • 为自定义工具和自定义工具命名空间留空。
  • 报告不完整: 如果使用 Visual Studio 的“发布”选项发布报告,但如果未正确发布,则报告可能会丢失内容或损坏。检查这一点的最佳方法是比较来自开发和生产/客户端计算机的报告大小。

  • 随机更改权限或安全/访问策略: 当报告有时有效但有时会引发错误时,这是​​一个可能的原因。如果您的应用程序对报告位置的权限是可变的/变化的,您可能需要检查应用于您的计算机/域的安全策略。 使用 Process Monitor 并查找任何拒绝访问错误或权限问题。

  • “加载报告失败”错误消息的所有可能原因 也适用于这个问题。这是作者写的最好的文章 Ludek 涵盖了所有内容。http://scn.sap.com/docs/DOC-21995

  • 导致此问题的另一个重要原因是 水晶打印引擎被超越。考虑一个场景,其中 应用程序执行多个视图/导出/打印功能 报告,报告在大多数情况下都可以正常工作,但会间歇性地抛出 这个例外。以下是您可能想要查看的文档 在解决这个问题。http://scn.sap.com/docs/DOC-21533

【讨论】:

  • 我用的是Winforms,没有Server.MapPath();我的代码是:public void ShowReport(DataTable dtdata) { crystalReportViewer.SelectionMode = CrystalDecisions.Windows.Forms.SelectionMode.None; ReportDocument rdoc = new ReportDocument(); rdoc.Load(@"@reports/rptBalanceSheet.rpt"); rdoc.SetDataSource(dtdata); crystalReportViewer.ReportSource = rdoc; }
  • @GrantWinney 感谢您的友好回复.. :) 我已经向您展示了代码。
  • @GrantWinney 对不起.. 你能帮帮我吗?我还在这个麻烦中。 :(
  • 我认为这可能是访问策略的问题,但不知道如何解决这个问题..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-02
  • 2011-07-22
  • 2012-04-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多