Skip to Content
0
Former Member
Nov 12, 2008 at 06:03 PM

CrystalReports 2008 SDK PrintToPrinter Hangs

131 Views

Hi,

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)

Report.Load(ReportName)

' Set the Report/SubReport Data Sources

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

Report.Database.Tables(i).SetDataSource(GetDataSource(Report.Database.Tables(i)))

Next

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

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

subreportTable.SetDataSource(GetDataSource(subreportTable))

Next

Next

' 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)

Else

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

End If

End Sub