0

First of all I would like to explain the pipeline and how the data il flowing in my scenario.

Components:

  • ASP.NET Application (IIS v8.5)
  • WCF Service Hosted on a Windows Service
  • Console Application

The ASP.NET Application sends the file path to the Web Service which in turn starts the console and passes the path as a command line argument. The console application should then proceed to print the PDF File for the given path.

When the console is run as a standalone the document is printed without any issues, but when the process is started by the windows service the application fails to print (Important to note that application does not crash either).

The Windows service was modified to Log On as the machine's Admin but the document is still not printed. The program was also tested in a Service without a WCF Service hosted in it, but the document did not print either.

It is also important to note that the Application Pool identity linked to the ASP.NET Application was also changed to reflect the machine's admin.

The console has no UI and user input and does not prompt the user in any way, but still fails to print when started from the service.

Has anyone encountered this issue and managed to solve it?

Jean Claude Abela
  • 782
  • 1
  • 9
  • 26
  • this is pretty hard for us to comment on - you will need to debug and isolate what is happening, typically by writing a log file from the service and seeing what happens; for example, does it *detect* the documents to print? can it find the printer? does it throw an exception while printing? we have no clue - you'll need to add logging. It isn't even clear to me (from the question) what communication pipe the service is using to listen for new things to print... – Marc Gravell Mar 22 '18 at 12:35
  • I did debug and log the whole process. The application does not seem to fail in any of the steps, as a matter of fact it looks like to the document passes to the printer but there is no output and the print queue remains empty. I also scoured the event log for any type of errors that might have been logged but there seems to be no entries. – Jean Claude Abela Mar 22 '18 at 12:41
  • Printing means the process needs to access the related resources (printer drivers, graphics, and so on) in a Windows session. A console app is launched by a process in your logon session which of course is fully supported by printing drivers. However, ASP.NET apps are launched by IIS in system session (session 0) where printing related resources are usually not available (or available in a completely different manner). Thus, most printing APIs are not supported in ASP.NET apps. Why cannot you do printing in a normal user session? – Lex Li Mar 22 '18 at 14:51
  • I apologise if I misguided you by my question, but as the title of the question shows, I am not trying to print from IIS but from a windows service. IIS is just the starting point of the pipeline which I listed so I could give the whole picture. To my knowledge services which log in as a user (not LocalSystem) are not executed in session 0 and therefore should have access to printers. – Jean Claude Abela Mar 23 '18 at 10:42

0 Answers0