Settings to access printer '\\hercules\prtmark01' are not valid
-
Friday, December 30, 2005 1:01 AMWe recently upgraded our web application to VS.Net 2005 and CR XIr2 from VS.Net 2003 & CR 9.2. We load a report using the ReportDoument class from a UNC path and call the PrintToPrinter method. It works fine on .Net 1.1 & CR 9.2 but with the .Net 2.0 web app & CR XIr2 we get the following error:
Exception Details: System.Drawing.Printing.InvalidPrinterException: Settings to access printer '\\hercules\prtmark01' are not valid.
Here is the code we use to load the report and print it:
oRpt.Load("\\pegasus\reports\warehouse\batchheader.rpt")
Dim crConnectionInfo As ConnectionInfo
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
crConnectionInfo = New ConnectionInfo
With crConnectionInfo
.ServerName = "***"
.DatabaseName = "***"
.UserID = "***"
.Password = "***"
End With
crDatabase = oRpt.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
oRpt.SetParameterValue("Company", iComp)
oRpt.SetParameterValue("CartBatchNbr", iCartBatchNbr)
Try
oRpt.PrintOptions.PrinterName = sPrinter
oRpt.PrintToPrinter(1, False, 0, 0)
Catch ex As Exception
sErr = "Unable to send Batch Header to printer '" & sPrinter & "'." & vbCrLf & ex.Message
Return False
Finally
oRpt.Close()
End Try
I can get both the .Net 2.0 & 1.1 web app to work on a Windows 2000 Server but only the .Net 1.1 application works on Windows 2003 Server.
Any Help would be appreciated. We will probably be opening a support case.
All Replies
-
Wednesday, August 30, 2006 4:11 PMDid you ever get this issue resolved? After upgrading to asp.net 2.0, we're having the exact same issue on our web server. Everything seems to work fine when running locally, but we get the InvalidPrinterException when PrintToPrinter is called from the Web server. If you've got any ideas on this, I'd love to heard them. Thanks.
-
Wednesday, August 30, 2006 11:01 PMModerator
hi,
you have to have an ntfs permission from the printer.
this has to be granted to you bby your network administrator
regards
joeydd
- Proposed As Answer by stu4231 Wednesday, May 20, 2009 5:12 PM
-
Wednesday, May 20, 2009 5:12 PM
for anyone still looking for a solution to this issue. It took me many hours of research but i finally got it goingyou need to stop the impersonation while you send the document to the printerfor additional infomation seeusing (WindowsImpersonationContext wic = WindowsIdentity.Impersonate(IntPtr.Zero)) { //code to send printdocument to the printer }
-
Monday, April 05, 2010 2:48 AMthe solution is stupid but it works.
-
Friday, August 27, 2010 5:42 PM
for anyone still looking for a solution to this issue. It took me many hours of research but i finally got it going
Don't forget to call wic.Undo() in a finally clause to make sure that the rest of the system goes back to how it was. No?
you need to stop the impersonation while you send the document to the printer
for additional infomation seeusing (WindowsImpersonationContext wic = WindowsIdentity.Impersonate(IntPtr.Zero)) { //code to send printdocument to the printer }
Pita.O:
http://www.arizentax.com/
http://www.cgi.com

