none
InvalidPrinterException !!! RRS feed

  • Question

  • I'm facing weird problem.

    After using months later my software properly on the same Windows 7 os, 

    my software gives 'InvalidPrinterExceptions' error on clint PC. 

    I think is security policy on printers.

    But except of my software printers run perfectly !!!

    At the same time in clint pc my software cant Access to default printer name, object, etc…

    I installed VS 2017 Comminity to my clint PC and debug error.

    "

    Me.PageSetupDialog2.PrinterSettings.PrinterName = DefaultPrinterName()
    Me.PrintDocument_hasilat_rapor.PrintController = New System.Drawing.Printing.StandardPrintController 'yazdırılıyor yazisi gözükmemesi için
    Me.PrintDocument_hasilat_rapor.Print()

    "

    Above Code Works on perfectly on developer PC and  other client PC's.

    Only one PC did not execute this lines!!!

    After firing "Me.PrintDocument_hasilat_rapor.Print()"

    it gives me. No installed printers, Invalid Printer Exceptions.

    I gave all users to all right to printer that  I take error.

    But nothing change.

    What can I do. 

    I think this is not about my software. After months something change in operating system about user right?


    Best regards...

    Saturday, June 23, 2018 6:22 AM

All replies

  • ali,

    That does not look like normal print document print code?

    You are using Visual Basic for .net Right?

    Why do you use PrintController?

    "PrintController is used by PrintDocument, and not typically used directly."

    https://msdn.microsoft.com/en-us/library/system.drawing.printing.printcontroller%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    What line do you get the error on?

    I dont see an error "'InvalidPrinterExceptions' " is that the exact error msg?

    Why set to the defaultprinter?

    What code is in the printpage event? Anything there making problems?

    What other error handling is working that may be interfearing? Perhaps you are getting an error on the other system you don't realize? Missing font? etc.


    How did the application get installed on the client?

    Saturday, June 23, 2018 1:44 PM
  • Dear sir,

    Thank You so much

    I reply to your answer.

    What line do you get the error on?

    "Me.PrintDocument_hasilat_rapor.Print()"

    This line gives error.

    But this line tousand times run properly on other pc installed Windows OS.

    Occurs this problem  only a few pc installed Windows OS.

    I install VS 2017 Comminty on PC than occur error.

    I debug line by line to catch error.

    I saw the line 

    "Me.PrintDocument_hasilat_rapor.Print()"

    But this line gives error on that PC, not mine, or other…

    I tought this is about Windows rights on printer ?

    Why set to the defaultprinter?

    I just tried get default printer name to set printer name.

    But this could not happen. The same way I got handle default printer name on other PC.

    Thanks for your help.

    Best regards.



    az

    Saturday, June 23, 2018 9:03 PM
  • ali,

    Try this on the problem computer and if it works then there is something about your current way of doing it. If it wont work then there is some other problem (assuming system has ms san serif font).

    This example shows the print preview (see image below). Select the print button on preview to print.

    Imports System.Drawing.Printing
    
    Public Class Form3
        Private WithEvents PrintDocument1 As PrintDocument = New PrintDocument
        Private WithEvents PrintPreviewDialog1 As New PrintPreviewDialog
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Try
                PrintPreviewDialog1.Document = PrintDocument1
                PrintPreviewDialog1.ShowDialog()
            Catch ex As Exception
                MsgBox("Printing Problem" & Chr(13) & ex.Message, MsgBoxStyle.Exclamation)
            End Try
        End Sub
    
        Private Sub PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            e.Graphics.DrawRectangle(Pens.Black, e.MarginBounds)
            e.Graphics.DrawString("Printer Test", New Font("ms sans serif", 14), Brushes.Black, e.MarginBounds.X, e.MarginBounds.Y)
    
        End Sub
    End Class

    Sunday, June 24, 2018 6:24 PM
  • Dear Sir,

    I ll realize your advice. And give you information after test.

    Thanks for your help.

    Best regards.


    az

    Sunday, June 24, 2018 8:40 PM
  • Hi ali

    Is your problem solved? If so, please mark the useful replies as answers. 

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, July 4, 2018 8:56 AM