Showing results for 
Search instead for 
Did you mean: 

CrystalReports 2008 SDK PrintToPrinter Hangs

Former Member
0 Kudos


I am using CrystalReports 2008 SDK (CrystalDecisions.CrystalReports.Engine) in a VB.NET 2008 Application. The application is Multi-Threaded and each thread can send a report to a printer asynchronously. The application is currently limited to 8 of these threads. The application prints any where from 50 to 100 reports a minute. Once or twice a week, all eight threads will hang on the call to CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(1, False, 1, 1).

Below is a sample of the code from the threads...

Private ManifestReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument

Private Sub PrintReport()


SubmitReport(EntryID, ReportName, PrinterName, Me.ManifestReport)


End Sub

Private Sub SubmitReport(ByVal EntryId As Long, _

ByVal ReportName As String, _

ByVal PrinterName As String, _

ByRef Report As CrystalDecisions.CrystalReports.Engine.ReportDocument)


' Set the Report/SubReport Data Sources

For i As Integer = 0 To Report.Database.Tables.Count - 1



For Each subReport As CrystalDecisions.CrystalReports.Engine.ReportDocument In Report.Subreports

For Each subreportTable As CrystalDecisions.CrystalReports.Engine.Table In subReport.Database.Tables




' Assign the EntryId to be Printed

Report.SetParameterValue("EntryId", EntryId)

' Send Report to Printer

If Not Me.PrintToFile Then

Report.PrintOptions.PrinterName = PrinterName

Report.PrintToPrinter(1, False, 1, 1)


Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.CrystalReport, "C:\Temp" & ReportName.Substring(ReportName.LastIndexOf("\")) & "_" & (EntryId Mod 56) & ".rpt")

End If

End Sub

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello, Robert;

This appears to be an issue with resources.

You have a main report with subreports each having a database connection using datasets in memory that will either print or export.

I do not see code that releases the report or dataset objects.

Crystal Reports still allocates 3 CPL using the out of the box application. That will handle between 30 and 50 reports at a time depending on complexity.

To make it more efficient it is recommended to release the report and dataset objects when you know the report has finished.

'Clean up the dataset in memory


dataSet = Nothing

'Clean up the report object



crReportDocument = Nothing

Let m know if that makes a difference.


Answers (2)

Answers (2)

Former Member
0 Kudos

Hello, Bob;

How many subreports are in each report? What section of the report holds them?

Are there any error messages in the Event logs of the application server?

Have you been able to run any tools such as Perfmon to check on system memory at the time it fails?


Former Member
0 Kudos


Thank you for your response!

I do already have code in my thread to cleanup the Report. I created a Dispose routine that is called by the application that creates and destroys the thread.

If ManifestReport IsNot Nothing Then

If ManifestReport.IsLoaded Then ManifestReport.Close()


ManifestReport = Nothing

End If

In order to speed up the processing of the application, I create the Database Adapters and Datasets when the application starts up and then I just re-fill them each loop of the main application. This helped to eliminate memory leaks and drastically increased performance. When monitoring the application the memory usage and the number of threads fluctuate but do not grow.

The application is printing approximately 50 Manifest Reports when there is information in the database to print. The application reads all the data necissary to print all of the reports. Then the application will loops through the reports and creates a thread to print each report. Only eight threads can be active at any given time. A request to print the set of Reports occurs approximately every minute.

Thank you,