InvalidPrinterException for Print() or PrintPreviewDialog()

B

bill

I got an exception when trying to start a PrintPreviewDialog or print for a
specific network printer. The code works for other network printers. That
printer works perfectly for all other applications. The exception happens
when PrintDocument.Print() is called or PrintPreviewDialog.ShowDialog() is
called. I set a breakpoint at the event handler. I has not been called yet
when the exception happened. I did check
PrintDocument.PrinterSettings.IsValid. It was true. Does anyone know how I
can further debug this problem? Thanks for your help. Here is the exception
in my VS.NET debugger and the code:

A first chance exception of type
'System.Drawing.Printing.InvalidPrinterException' occurred in
system.drawing.dll
Additional information: Tried to access printer '\\abc\printer1' with
invalid settings

I then clicked "continue". The message appeared for three times. Then, an
error message dialog came up with

************** Exception Text **************
System.Drawing.Printing.InvalidPrinterException: Tried to access printer
'\\abc\printer1' with invalid settings.
at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

==========================================================
PrintDocument pd = new PrintDocument();
pd.PrintPage +=new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName = name;

if (isPrint)
{
pd.Print();
else
{
this.printPreviewDialog1.Document = pd;
this.printPreviewDialog1.ShowDialog (this);
}
 
B

bill

Hi Bob,
Thanks fro your response. It is a HP LaserJet 4000. I have another HP
LaserJet 4000. It works perfectly. I am really confused about what may go
wrong. Thanks.
 
K

Kathy Rathy

I am getting the same error on an HP LaserJet 4000 with a HP LaserJet
4000 Series PCL 6 driver. If I use a different driver on the same
printer I don't have any problems. Ideas as to what could be wrong?
Or suggestions on how to debug it further?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top