CrystalReport加载报告失败

mSa*_*del 12 .net c# crystal-reports

我有一个使用Crystal Report 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)
Run Code Online (Sandbox Code Playgroud)

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

Joh*_*yer 19

如果您的应用程序是独立的可执行文件,则会生成此错误,因为在完成任何操作后,您没有正确关闭报表对象.您可能会在应用程序中看到此错误作为ASP.NET应用程序运行,并且有许多用户同时访问您的站点.

您可以通过调整此注册表项来更快地显示错误:

HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit
Run Code Online (Sandbox Code Playgroud)

它通常默认为75.对于调试,您可以将其设置为较小的值,并使错误更快出现.

完成使用报表对象后,请调用.Close()方法,该方法将清除所使用的未管理资源.

有些人提到将设置更改为-1.这是一个错误,它只会导致长时间运行的应用程序出现其他问题.该过程最终会耗尽资源,并以更难以排除故障的方式开始失败.

  • 我在这里阅读http://devlibrary.businessobjects.com/businessobjectsxir2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crconsdkfundamentalsscalabilityclosemethod.htm,在Page_Unload事件期间调用Close()方法的正确时间. (2认同)

Sea*_*nJA 0

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