PrintDocument.PrinterSettings.IsValid always return false!? RRS feed

  • Question

  •  Sorry my English is very poor. I try my best say clearly.

    I writed a project for Winform use VC#2008, Framework used V2.0 , some PC have a owner printer ,but one or two of them when goto PrintDocument.PrinterSettings.IsValid  is always return false and can not print . Here is code

     PrintDocument printDoc = new PrintDocument();

                if (!printDoc.PrinterSettings.IsValid)
                    MessageBox.Show("Error: cannot find the default printer.");
                    return false;

    but no all pc has this error. If a pc show this error,  only way is restart it .  I had try exit the program and re-login ,but it still happen, and others program  could using printer normally like word,excel and so on. Is there some bug in PrintDocument ?

    Friday, August 10, 2012 3:05 AM

All replies

  • Is the DefaultPrinter selected?  If you iterate through the InstalledPrinters, is there a default printer?  Is it valid?  Is the InstalledPrinters.Count > 0?
    Friday, August 10, 2012 7:24 AM
  • It is default printer ,the valid is null , but the other program can use that printer, i try to change default printer ,print the file to a net printer ,it is work. When i select that printer which that local printer in print dialog , it show error again. If i reset the PC, it will be fine , and that error will come again hours later or days

    Monday, August 13, 2012 2:47 AM