D
Dan Schullman
Hello,
I've got some executables that need to run both as a Windows Service and
independently. How can I in my .NET code determine the environment/context
in which they're running?
For example, one executable is the service executable AND a CLI utility to
manage that service. Another needs to know the mode to figure out how to
handle logging (e.g., use EventLog or write to STDOUT).
By the way, I also noticed that contrary to the docs for ServiceBase.Run(),
it does NOT throw an exception when invoked from a command line program but
rather pops up a GUI error message and then simply returns, so the caller
presumably has no way to know that it failed.
Thanks,
Dan S.
I've got some executables that need to run both as a Windows Service and
independently. How can I in my .NET code determine the environment/context
in which they're running?
For example, one executable is the service executable AND a CLI utility to
manage that service. Another needs to know the mode to figure out how to
handle logging (e.g., use EventLog or write to STDOUT).
By the way, I also noticed that contrary to the docs for ServiceBase.Run(),
it does NOT throw an exception when invoked from a command line program but
rather pops up a GUI error message and then simply returns, so the caller
presumably has no way to know that it failed.
Thanks,
Dan S.