views:

4023

answers:

5

I have a windows application project (C# and .NET 2.0) that used Crystal Report 2008. But I get error sometimes (it seems accidentally) in loading report. That error is:

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)

please guide me. How can I solve this problem?

A: 

I've run into this problem before ... the first thing I would do is check to make sure the report path is correct.

mattruma
A: 

The internet also suggests reinstalling the crystal report runtimes on the machines you are trying to open the report on (making sure that all locations have the same version).

SeanJA
thanx SeanJA. i should test this solution.
mSafdel
Maybe it'll work for you. Didn't work for me - still stuck with this same problem.
David T. Macknet
+3  A: 

If your application is a standalone executable then this error is generated because you are not properly closing your report object when you are done with it. You might see this error running you application as an ASP.NET app with a lot of users accessing your site simultaneously.

You can cause the error to appear sooner by tweaking this registry key:

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

It normally is defaulted to 75. For debugging you can set it to a smaller value and cause the error to appear sooner.

When you are done using a report object, call the .Close() method which will clean up the unmanaged resources used.

There are those that mention to change the setting to -1. This is a mistake, it will only cause other problems for an application that is long running. The process will eventually run out of resources and start to fail in ways that will be even more difficult to troubleshoot.

John Dyer
A: 

FYI, I have just verified this solution for a similar problem. The ReportDocument.Load method was failing when using a mapped network share or UNC path and installing the crystal reports VS runtime on the file server fixed the problem.

spm
A: 

I have verified John Dyer's solution, above, does not work in all cases.

I have also verified that reinstalling Crystal Runtime did no good for this particular error.

For my app this was only happening on Citrix installs of a stand-alone .exe, with embedded reports. Before using the Crystal Report Viewer, I need to make sure that I've cleared out any report previously loaded in the viewer, as per John's instructions. So, I'll wrote something (in VB) which looks like

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

where CleanOutViewer is:

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

The calls after .Close() also had no effect (and were added as an alternate attempt to try to force the Crystal to release resources).

David T. Macknet
Also: using embedded resources rather than reports stored on the file system has no effect - I've never done so and am getting this error.
David T. Macknet