0

I have a background process which is a .NET Executable which runs without the STAThread attribute. It is NOT a windows service. This executable is meant to run as a background process without any user interaction.

This background process polls a database table for jobs it may have to dispatch to a printer connected to the computer.

I use an instance of the C# PrintServer (MSDN) class. I create an instance of the print server, get a reference to a queue specified by user input and then add a job with the PrintQueue.AddJob() (MSDN). And then I call the PrintServer.Commit() function call. This works fine with almost all "real" printers. When it comes to document printers such XPS, Adobe PDF etc or a "real" printer which pops up an additional dialog afterwards, this dialog is not displayed.

This is my problem. The extra dialog is not displayed. This means that the print job never finishes. However, when I use this same sequence of events for a regular console program, there are no hassles.. the printer driver displays the dialog to the user. Please note that this problem is seen mostly with "virtual" or document printers, however in my testing I found that a printer which pops up an additional dialog is also susceptible to this problem.

While I'm currently circumventing the problem with a verification process before allowing users to print to a specific printer, the problem of the missing dialog still remains.

I've already looked at questions for how to detect a document/software printer on Stackoverflow and the Microsoft community forums. However, they all list detecting whether the printer is virtual or not. I've found that there are no longer any sure fire ways to distinguish a virtual/document printer from a physical/real printer.

Any help is appreciated.

Thanks!

abjbhat
  • 999
  • 3
  • 13
  • 24
  • 1
    "a .NET Executable which runs without the STAThread attribute" - why? Your problem is almost certainly that missing `STAThread` attribute, see https://blogs.msdn.microsoft.com/jfoscoding/2005/04/07/why-is-stathread-required/ – Ian Kemp Mar 03 '16 at 06:59
  • My test console program runs without the STAThread attribute. There are no problems with the dialog being displayed. – abjbhat Mar 03 '16 at 12:25

0 Answers0