ServiceBase Constructor ()
Creates a new instance of the ServiceBase class.
Assembly: System.ServiceProcess (in System.ServiceProcess.dll)
Do not create an instance of the ServiceBase class. Instead, derive from ServiceBase and instantiate your derived class. The minimum you need to implement in the constructor for a class inherited from ServiceBase is to set the ServiceName on your component. No other processing is specifically required in the constructor. You should handle most initialization in OnStart rather than in the constructor. Otherwise, there is no guarantee the objects will be reinitialized when you restart a service after it has been stopped.
If you override the constructor in your derived class, call the base class constructor in your code.
If the executable contains a single service, the system calls the service's constructor when Start is selected from the SCM, and runs the destructor if Stop is called.
If the executable contains multiple services, calling Start on one service causes the constructors to be called for all services in the executable, but only the specified service is started. Destructors for the services are run together when all services have been stopped, not individually when each service is stopped.
If you override the base class constructor, you should explicitly call it in the constructor of your derived class.
Available since 1.1