0

I have a c# console application that is using WebBrowser control and print documents to a printer. I have scheduled that job to run everyday using Task Scheduler.

When I run the console app exe with option "Run Only when user is logged on" everything works fine. However when I change it to "Run whether user is logged on or not", my process fails and I see following in the Event Viewer.

enter image description here

Faulting module name: MSHTML.dll, version: 11.0.9600.18792, time stamp: 0x59908408
Exception code: 0xc0000005
Fault offset: 0x00bd397f
Faulting process id: 0x2768

Why is webBrowser not working with "Run whether user is logged on or not" Any ideas ? Thanks all.

Ref: Print WebBrowser without previewing i.e. single click print

ProgSky
  • 2,530
  • 8
  • 39
  • 65

1 Answers1

1

The web browser control aka IEFrame.dll is like a version of IE running with the frame process and tab processes combined into thread loaded into the memory space of your application.

As such, they suffer from the same issues that IE does. Since IE is build on top of WinInet and WinInet is not supported for running in session 0 (aka when the user is not logged on), this is likely to fail. The reason is IE and WinInet load settings from the HKEY_CURRENT_USER registry hive, which is not available if you are not logged in.

It sounds like you just need an HTML rendering engine to print documents.

Source(s) I used to be on the Microsoft Premier Support Team for IE Development.

Alexander Ryan Baggett
  • 2,347
  • 4
  • 34
  • 61
  • Thanks Alex! Appreciate detailed explanation. I am exploring wkhtmltopdf to convert html to pdf. – ProgSky Oct 04 '17 at 18:21