ServiceBase::Run Method (ServiceBase)
Registers the executable for a service with the Service Control Manager (SCM).
Assembly: System.ServiceProcess (in System.ServiceProcess.dll)
Parameters
- service
- Type: System.ServiceProcess::ServiceBase
A ServiceBase which indicates a service to start.
| Exception | Condition |
|---|---|
| ArgumentException | service is nullptr. |
Call this overload in the main() function of the service executable to register the service with the Service Control Manager. After you call Run(ServiceBase), the Service Control Manager issues a Start command, which results in a call to the OnStart method in the service. The service is not started until the Start command is executed.
The ServiceBase::Run method is called in much the same way as Application::Run for Windows Forms applications.
If AutoLog is true, an entry is written to the event log if the service specified by the service parameter fails to start.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.