When System.Drawing.Printing.PrinterSettings.PrinterName is used for identifying the default printer, it gives the wrong value(Last installed printer in the system). The application is running as a Windows service with Log On user as Local system account and it is expected to print to the system's default printer .
When the same application is running as desktop application, it returns the correct default printer.
When the application is running as Windows service:
System.Drawing.Printing.PrinterSettings.PrinterName returns Printer A as default printer. PrinterSettings.IsDefaultPrinter is also "true".
In the system, Printer B is set as default printer.
When the same application is running as desktop application,
System.Drawing.Printing.PrinterSettings.PrinterName returns Printer B
In the system, Printer B is set as default printer.
My understanding is System.Drawing.Printing.PrinterSettings.PrinterName always gives the system default printer. If not PrinterSettings.IsDefaultPrinter can be used to identify the default printer but it looks like System.Drawing.Printing.PrinterSettings.PrinterName property is giving wrong value.
Because of this the service is always printing to the latest installed printer rather than printing to the default printer in the system. I verified there are no setup problem in the system. Is this a problem with System.Drawing dll
The printers are connected to the system directly.