Export (0) Print
Expand All

ServiceBase.Run Method (ServiceBase)

Registers the executable for a service with the Service Control Manager (SCM).

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

public static void Run(
	ServiceBase service
)

Parameters

service
Type: System.ServiceProcess.ServiceBase

A ServiceBase which indicates a service to start.

ExceptionCondition
ArgumentException

service is null.

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.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft