on 03-10-2009 6:06 PM
I am using VB 2008 and Visual Studio 2008 I use the version of CR that comes with VS 2008. I have created an application which prints reports. The application works 97% of the time with no issue. Occasionally, I will get the following error:
Error Message: The Report Application Server failed
HelpLink:
Source: RptControllers.dll
Target (Method): Int32 GetLastPageNumber(CrystalDecisions.ReportAppServer.ReportDefModel.RequestContext)
Stack Trace: at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.GetLastPageNumber(RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at Workflow_WPF.ReportPrinting.PrintPrimaryRLRecordCopy(objVisitData w)
My source code is:
Dim PrimaryRL As New rptReferralLetter
Try
If DetermineIfPrinterHasError(My.Application.PrinterSettings.ActivePlainPrinter) = False Then
PrimaryRL.SetDataSource(PrimaryReportDataSource)
PrimaryRL.PrintOptions.PrinterName = My.Application.PrinterSettings.ActivePlainPrinter
PrimaryRL.PrintOptions.CustomPaperSource = My.Application.PrinterSettings.ReturnPaperSource(My.Application.PrinterSettings.ActivePlainPrinter, My.Application.PrinterSettings.ActivePlainTray)
PrimaryRL.PrintToPrinter(1, False, 1, 100)
PrimaryRL.Close()
System.Threading.Thread.Sleep(500)
Else
MessageBox.Show("The printer reports that there is an error. You must correct this error before you can print. The reported message is: " & vbCrLf & vbCrLf & PrinterErrorString, My.Application.GlobalSettings.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Information)
End If
Catch ex As Exception
MessageBox.Show("There was an error printing the record copy of the referral letter. It may need to be reprinted.", My.Application.GlobalSettings.ApplicationName, MessageBoxButton.OK)
End Try
PrimaryRL.Dispose()
PrimaryRL = Nothing
CleanUpReportData()
When the user simply clicks to print again, it works just fine. I cannot replicate the error and do not know how to prevent this from happening. This is always the third report printed in a row. The first is another similar page with identical code. The second is an envelope. The third is this page with this code. The error localizes the problem to this particular procedure.
I use 100 as the last page in code since I cannot predict the length of the report. It is usually 1-2 pages.
Have you tried using PrintToPrinter(1, False, 0,0)? This tells it to print all pages, rather than guessing at how many pages the report is going to be.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.