Is there a way for an .NET library to detect whether or not it is being run as a service?
My library can be run either way. But when its run as a service, developer
One way is to have a look at the user context of your application. If you see that it is running as the "SYSTEM" user, then you are running as a service (or at least with service-level permissions).