title: Detect if code is running as a service
body: <p>Is there a way for an .NET library to detect whether or not it is being run as a service? </p>
  
  <p>My library can be run either way. But when its run as a service, developers need to call an additional method indicating that fact or certain features won't work correctly. I want my library, which handles logging, to write a warning if it is used in a service without that method being called.</p>