This documentation is archived and is not being maintained.

ServiceBase.Run Method (ServiceBase[])

Registers the executable for multiple services with the Service Control Manager (SCM).

Namespace:  System.ServiceProcess
Assembly:  System.ServiceProcess (in System.ServiceProcess.dll)

public static void Run(
	ServiceBase[] services
)

Parameters

services
Type: System.ServiceProcess.ServiceBase[]
An array of ServiceBase instances, which indicate services to start.

ExceptionCondition
ArgumentException

You did not supply a service to start. The array might be null or empty.

Call this overload in the main() function of the service executable to register the services with the Service Control Manager. After you call Run(ServiceBase[]), the Service Control Manager issues Start commands, which result in calls to the OnStart methods in the services. The services are not started until the Start commands are executed.

The ServiceBase.Run method is called in much the same way as the Application.Run method for Windows Forms applications.

If AutoLog is true, an entry is written to the event log if any service in the array fails to start.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Show: