CrystalReport负载报告失败(CrystalReport Load report fail

2019-06-26 19:49发布

我有一个用2008水晶报表Windows应用程序项目(C#和.NET 2.0),但我得到的错误,有时(似乎一不小心)装载报告。 这错误是:

CrystalDecisions.Shared.CrystalReportsException: Load report failed.
System.Runtime.InteropServices.COMException (0x8000020D): Unable to load report.
   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 SIA.DataTransfer.Forms.frmReport.GetStateReport(Int32 transferType)

请指导我。 我怎么解决这个问题?

Answer 1:

如果您的应用程序是一个独立的可执行文件,然后将生成此错误,因为你不关闭你的报表对象妥善当你与不管你做什么来完成。 您可能会看到在您的应用程序有很多用户同时访问你的网站的ASP.NET应用程序运行此错误。

您可能会导致错误通过调整此注册表项更快地出现:

HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit

它通常被默认为75.为了调试,你可以将其设置为较小的值,并导致错误出现越早。

当您使用报表对象做了,呼吁将清理所使用的非托管资源的.Close()方法。

还有那些提到的设置更改为-1。 这是一个错误,它只会导致其他问题的一个应用程序是长时间运行。 这一过程将最终耗尽资源和启动的方式,将更加难以解决失败。



Answer 2:

增加CurrentJobLimit是解决不了问题; 如果计数器没有被重置这个数字将达到。
为了避免工作计数器增加,您需要关闭水晶报表文件( ReportSource.Close()编程。

protected void Page_Unload(object sender, EventArgs e)
 {
    CrystalReportViewer1.ReportSource.Close();
 }

这是为了避免继续打开的报告中提高的唯一途径,由计CurrentJobLimit



Answer 3:

我已经验证约翰·戴尔的解决方案, 以上的 ,不工作在所有情况下。

我也已经验证了重新安装水晶运行时做无益于这个特定的错误。

对于我的应用程序,这只是发生在思杰的独立的.exe安装,内嵌报告。 使用Crystal报表查看器之前,我需要确保我已经清理了以前在浏览器加载的任何报告,按照约翰的指示。 所以,我写的东西(在VB中)看起来像

Public Function ShowRpt(...) As Boolean
    ....
    CleanOutViewer()
    ....
End Function

其中CleanOutViewer是:

Private Sub CleanOutViewer()
    If Not Me.CrystalReportViewer1.ReportSource() Is Nothing Then
        CType(Me.CrystalReportViewer1.ReportSource(), CrystalDecisions.CrystalReports.Engine.ReportDocument).Close()
        CType(Me.CrystalReportViewer1.ReportSource(), CrystalDecisions.CrystalReports.Engine.ReportDocument).Dispose()
        Me.CrystalReportViewer1.ReportSource() = Nothing
        GC.Collect()
    End If
End Sub

.Close后的()的调用也没有效果(并加入作为备用的尝试,试图迫使水晶释放资源)。



Answer 4:

水晶报表文档需要手动设置。

你应该控制所有报告的寿命在您的应用程序,并达到75限制之前调用它们丢弃。

有关于如何在这个环节上做到这一点的好办法:

http://geekswithblogs.net/technetbytes/archive/2007/07/17/114008.aspx



Answer 5:

互联网还建议重新安装机器上的水晶报表运行时您正在尝试打开(确保所有位置具有相同的版本)的报告。



Answer 6:

仅供参考,我刚才已经验证了这一解决方案类似的问题。 该ReportDocument.Load方法,使用映射的网络共享或UNC路径并安装固定的问题在文件服务器上的晶体报告VS运行时失败。



文章来源: CrystalReport Load report failed