Error: Failed to open the _PRINTERNAME_ printer, System error number: 5


11-25-2009, 1:29 AM
When running a Report I receive the following exception:

Failed to open the \\GROEN-NT17\SM - Informatica - Kyocera FSC2525 printer, System error number: 5

The stacktrace shows the exception got thrown when retrieving the papersize, however the papersize
has been defined custom papersize.

When running on the desktop, I dont have this problem, and until recently, I did neither had it on my labtop.
I did not change the printer recently, and its working correctly.

[CODE]
        Dim Report As New _QDOC_INFOHOS.Aanvragen(Rows, Tot, Dienst, PatientType, Title, WriteDifference)
        Report.Run() '' <= Exception thrown here
[/CODE]

STACKTRACE:
[CODE]
"   bij DataDynamics.ActiveReports.Document.DDPaperSize.-fad(String printerName, String paperName, Single width, Single height)    bij DataDynamics.ActiveReports.Document.DDPaperSize..ctor(String printerName, String paperName, Single width, Single height)    bij DataDynamics.ActiveReports.ActiveReport3.-1be()    bij DataDynamics.ActiveReports.ActiveReport3.-0a2(Boolean bDelayedInit)    bij DataDynamics.ActiveReports.ActiveReport3.Run(Boolean syncDocument)    bij DataDynamics.ActiveReports.ActiveReport3.Run()    bij AZGroeninge.Exp2.Reports.QDOC_INFOHOS.GenerateRapportByAanvraag(IList`1 Rows, String Tot, String Dienst, String PatientType, String Title, Boolean WriteDifference) in C:\Documents and Settings\pgoethal\Mijn documenten\Visual Studio 2008\Projects\AZGroeninge.Pieter\AZGroeninge.Exp2.ActiveReports\QSOC_INFOHOS\QDOC_INFOHOS.vb:regel 233    bij AZGroeninge.Exp2.Reports.QDOC_INFOHOS.GenerateRapportsFromFlatfileData(String FFData, String SavePath, String Tot, String Dienst, ProgressController PBC) in C:\Documents and Settings\pgoethal\Mijn documenten\Visual Studio 2008\Projects\AZGroeninge.Pieter\AZGroeninge.Exp2.ActiveReports\QSOC_INFOHOS\QDOC_INFOHOS.vb:regel 428    bij AZGroeninge.Exp2.Reports.QDOC_INFOHOS.GenerateRapports(String Root, DateTime Tot, eDienst Dienst, ProgressController PBC) in C:\Documents and Settings\pgoethal\Mijn documenten\Visual Studio 2008\Projects\AZGroeninge.Pieter\AZGroeninge.Exp2.ActiveReports\QSOC_INFOHOS\QDOC_INFOHOS.vb:regel 324    bij TabQDocInfohosApotheek.Generate.GenerateRapports(String DienstString, ProgressController PBControl) in C:\Documents and Settings\pgoethal\Mijn documenten\Visual Studio 2008\Projects\TabQDocInfohosApotheek\TabQDocInfohosApotheek_SC\Generate.vb:regel 119    bij TabQDocInfohosApotheek.Generate.GenerateRapports_Catch(Object[] Params) in C:\Documents and Settings\pgoethal\Mijn documenten\Visual Studio 2008\Projects\TabQDocInfohosApotheek\TabQDocInfohosApotheek_SC\Generate.vb:regel 126    bij TabQDocInfohosApotheek.Generate._Lambda$__1(Object a0) in C:\Documents and Settings\pgoethal\Mijn documenten\Visual Studio 2008\Projects\TabQDocInfohosApotheek\TabQDocInfohosApotheek_SC\Generate.vb:regel 129    bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)    bij System.Threading.ExecutionContext.runTryCode(Object userData)    bij System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)    bij System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)    bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    bij System.Threading.ThreadHelper.ThreadStart(Object obj)"
[/CODE]

Re: Error: Failed to open the _PRINTERNAME_ printer, System error number: 5


11-25-2009, 3:25 AM
Pieter,

From the code you have provided it looks that you are using a network printer. It looks as though that the application is trying to retrieve settings from the default printer on the system, but does not have access to it.

Could you please try setting the PrinterName Property to an empty string? This will tell ActiveReports for .NET to use its virtual printer to get paper size settings:
e.g. myReport.Document.Printer.PrinterName = "";

You may also want to take a look at this Microsoft link which explains how you can install the network printer locally. You may also want to reinstall the printer drivers rather than just use the one that had been copied across the network previously.

Do let me know if you still face any issues.

Regards,
Sankalp
Sankalp Sen
GrapeCity- DataDynamics

Re: Error: Failed to open the _PRINTERNAME_ printer, System error number: 5


11-25-2009, 4:56 AM
I'm not really sure why the report tried to access a printer,
however changing the printername to an emtpy string worked like a charm.
Thx!

Re: Error: Failed to open the _PRINTERNAME_ printer, System error number: 5


03-03-2010, 4:40 PM
This was happening to me when I simply designed the report to be landscape. The fix was to specify the PageSettings.Paperkind to be PaperKind.Letter