$100 bounty for help with Windows Service code
Vladimir Panteleev via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 17 15:12:06 PDT 2014
On Sunday, 17 August 2014 at 21:24:24 UTC, Tyler Jensen wrote:
> I've coded up a Windows Service that ALMOST works but I'm
> missing something. I need your help.
Hi,
The service works as expected on my Windows machine, but it shows
the symptoms you described on my Windows XP VM. I'm going to
assume that the symptoms indicate the same problem for my VM and
your system.
The reason for the 1053 error is that the service hangs before it
can contact the service manager. It is terminated after 5 seconds.
If you use Process Explorer (freeware) or Process Hacker
(open-source) to peek at the service process's stack trace,
you'll notice that it shows a message box. The message box is not
visible to the desktop user, because it is being displayed on the
hidden service window station.
When the D runtime encounters an unhandled exception, it will
print the exception stack trace to standard error stream, if it
is valid. However, services have no standard output or error
stream, so the runtime shows a MessageBox instead. (Incidentally,
I implemented that behavior.) Thus, the service hangs because of
an unhandled exception.
The exception is:
std.exception.ErrnoException at std\stdio.d(367): Cannot open file
`c:\temp\inc.log' in mode `a' (Permission denied)
This occurs when the service process attempts to add a line to
the log file. However, as the log is owned by the desktop user
(because it was created by a process started as the desktop
user), and the service process runs under as the "NT
AUTHORITY\NETWORK SERVICE" user, the service process cannot write
to the same log file as the process starting the service.
More information about the Digitalmars-d
mailing list