Export (0) Print
Expand All

ServiceBase.Run Method (ServiceBase)

Provides the main entry point for an executable that contains a single service. Loads the service into memory so it can be started.

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

public static void Run (
	ServiceBase service
)
public static void Run (
	ServiceBase service
)
public static function Run (
	service : ServiceBase
)

Parameters

service

A ServiceBase which indicates a service to start.

Exception typeCondition

ArgumentException

service is a null reference (Nothing in Visual Basic).

Win32Exception

You tried to start the service from the command line.

Call this overload in the main() function of the service executable to load a single service. 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.

ServiceBase.Run 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 .

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

Community Additions

ADD
Show:
© 2015 Microsoft