This documentation is archived and is not being maintained.

ServiceBase.Run Method (ServiceBase[])

Provides the main entry point for an executable that contains multiple associated services. Loads the specified services into memory so they can be started.

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

public static void Run (
	ServiceBase[] services
)
public static void Run (
	ServiceBase[] services
)
public static function Run (
	services : ServiceBase[]
)

Parameters

services

An array of ServiceBase instances, which indicate services to start.

Exception typeCondition

ArgumentException

You did not supply a service to start. The array might be a null reference (Nothing in Visual Basic) or empty.

Win32Exception

You tried to start the service from the command line.

Call this overload in the main() function of the service executable to load an array of associated services. When you call Run on a service, it is loaded into memory. The service is not started until the Service Control Manager passes a Start command to the service.

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.

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: