[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

InvalidPrinterException for Print() or PrintPreviewDialog

bill

10/23/2004 12:50:00 AM

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);
}


3 Answers

Bob Powell

10/23/2004 9:47:00 AM

0

Which specific printer model is it? Have you installed the latest drivers
for that printer?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob's Blog: http://bobpowelldotnet.blogspot.co...






"bill" <bill@nospamland.com> wrote in message
news:OHviopJuEHA.1372@TK2MSFTNGP14.phx.gbl...
> 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);
> }
>
>


bill

10/25/2004 5:41:00 PM

0

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.


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:uSMg9UOuEHA.2196@TK2MSFTNGP14.phx.gbl...
> Which specific printer model is it? Have you installed the latest drivers
> for that printer?
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/gdipl...
>
> The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
> Bob's Blog: http://bobpowelldotnet.blogspot.co...
>
>
>
>
>
>
> "bill" <bill@nospamland.com> wrote in message
> news:OHviopJuEHA.1372@TK2MSFTNGP14.phx.gbl...
> > 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);
> > }
> >
> >
>
>


kathy.rathy

11/16/2004 10:13:00 PM

0

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.