cancel
Showing results for 
Search instead for 
Did you mean: 

Intermittent "Invalid printer specified" error from PrintToPrinter

former_member602362
Discoverer
0 Kudos

I am intermittently getting an error stating "Invalid printer specified" when calling the PrintToPrinter function.

at CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.ModifyPrinterName(String
newVal)
at CrystalDecisions.CrystalReports.Engine.PrintOptions.set_PrinterName(String
value)
at NFGCrystalRun.NFGCrystalRun.NFGCrystalRun.NFG_runReport()

The error seems to occur more frequently when there are multiple instances of the process being run at the same time, but from what I understand, Crystal supports up to 75 instances at a time.

I see some posts regarding similar issues but no specific resolutions.

I am using the Crystal runtime for Visual Studio, 64-bit, version 13.0.24.

Windows Server 2016

Visual Studio 2012

The issue occurs on multiple printers, but the main one that we use is a Toshiba E-studio5560C.

Accepted Solutions (1)

Accepted Solutions (1)

You are using RAS and then the Engine to set and print, don't mix them.

See this printer test app:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

Then download this printer test app, use a report with saved data:

Printing Crystal Reports in .NET

Don

former_member602362
Discoverer
0 Kudos

Don,

Thank you for your response. I know that the stack trace references both RAS and the Engine, but that is not actually what is being done in the code. Our code is:

crReportDocument.PrintOptions.Printername = printerPath
crReportDocument.PrintToPrinter(1, False, 0, 0)

That said, I think that I can modify it to use the RAS based on what I see in your test app. Do you agree?

Dim popt As CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions = New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
popt.PrinterName = printerPath
crReportDocument.ReportClientDocument.PrintOutputController.PrintReport(popt)

- Dan

Answers (1)

Answers (1)

0 Kudos

Yes, use POC, it's much better at printing.

And for more report details have a look at this one as well:

how-to-parameters-in-crystal-reports-for-visual-studio-net

As for the error, do you know it's CR causing the problem or the printer driver?

DLL's typically can't pass errors very well and it's usually the last dll the reports the error, in this case CR is simply passing that error to you from somewhere.

Search MSDN, there are samples on how to query the Print Spooler to get more details from the printer and what that error may be caused by.

I suspect it's the printer possibly running out of memory and going into a non-functioning state or too many threads going to it or... could be lots of things.

By using PrintOutputController it's uses CR's printer dialog box and not the Framework's print routines, which are very generic in it's abilities.

You can change the default in the Viewers Print button to use the POC, see sample on how to.

Don