SAP Knowledge Base Article - Public

1583572 - memory leak when accessing the ReportDocument.PrintOptions class

Symptom

The following error messsage appears when looping to access Reportdocument.PrintOptions class from .NET application.

Not enough memory for operation.
System.Runtime.InteropServices.COMException (0x80041004): Not enough memory for operation.
at CrystalDecisions.ReportAppServer.Controllers.PrintOutputController Class.ModifyPrintOptions(PrintOptions newVal)
at CrystalDecisions.CrystalReports.Engine.PrintOptions.set_Dissociate PageSizeAndPrinterPaperSize(Boolean value)
at CrystalDecisions.CrystalReports.Engine.PrintOptions.Copy(PrintOptions src)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_SummaryInfo()
at SPC001.SMKS_SPC001.DoPrintSTL00301(String strBodyXML, ReportHead & reportHead)

Environment

  • Crystal Reports 2008 V1
  • Visual Studio 2005/2008

Reproducing the Issue

VB.NET application contains looping to access ReportDocument.PrintOptions class and error occurrs after 16381 print jobs.

e.g.

reportObj.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Vertical

reportObj.PrintOptions.PrinterName = "<Printer Name>"

reportObj.SummaryInfo.ReportTitle = "<Report Title>"

reportObj.SetDataSource(ds)

reportObj.PrintToPrinter(1, False, 0, 0)

Cause

The issue has been identified and tracked under ID ADAPT01540713.

 

Resolution

The issue is scheduled to be fixed in Fix Pack 3.7.

Workaround: ReportDocument.PrintOptions class program code is converted to RAS SDK.

e.g.

Imports CrystalDecisions.ReportAppServer.ClientDoc

Imports CrystalDecisions.ReportAppServer.DataDefModel

Imports CrystalDecisions.ReportAppServer.Controllers

Imports CrystalDecisions.ReportAppServer.ReportDefModel 

Dim rcd As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument

Dim prnOpts As CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions

rcd = rpt.ReportClientDocument

prnOpts = rcd.PrintOutputController.GetPrintOptions()

prnOpts.PrinterDuplex = CrystalDecisions.ReportAppServer.ReportDefModel.CrPrinterDuplexEnum.crPrinterDuplexVertical

prnOpts.PrinterName = "<Printer Name>"

rcd.PrintOutputController.ModifyPrintOptions(prnOpts)

Keywords

memory leak, PrintOptions, .net, Windows, application, RAS , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1