Skip to Content
0
Former Member
Dec 02, 2011 at 09:08 AM

"The Handle Is Invalid" error when printing from CR2010/VS2010 application.

815 Views

Hi there

I have written a windows service (in VB) that prints reports using Visual Studio 2010 and Crystal for VS 2010.

When this service runs under the Local System account it works fine but when I run it under the Local Administrator account (or any other account) it fails with an 'The Handle Is Invalid' error.

The code that does the printing is as follow:

Dim printDoc As New ReportDocumentprintDoc.Load(ReportPath & "\Blank.rpt")

printDoc.PrintOptions.PrinterName = "Olivetti Job Card Colour"

printDoc.PrintToPrinter(1, False, 1, 99)

The last line causes the error.

The OS is Windows Server 2008 x64.

I have tried varius different security setting for the admin account but cannot get it to print under the admin account and unfortunately there are other requirements that dictates that I cannot use the Local System account to print.

Any help on this would be greatly appreaciated.

Regards

Edu