Export (0) Print
Expand All

ServiceController.ServiceName Property

Gets or sets the name that identifies the service that this instance references.

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

[TypeConverterAttribute(typeof(ServiceNameConverter))] 
public string ServiceName { get; set; }
/** @property */
public String get_ServiceName ()

/** @property */
public void set_ServiceName (String value)

public function get ServiceName () : String

public function set ServiceName (value : String)

Not applicable.

Property Value

The name that identifies the service that this ServiceController instance references. The default is an empty string ("").

Exception typeCondition

ArgumentNullException

The ServiceName is a null reference (Nothing in Visual Basic).

ArgumentException

The syntax of the ServiceName property is invalid.

The ServiceName identifies the service to the Service Control Manager. Changing this property causes the ServiceController instance to bind to another service, it does not change what the Service Control Manager's Microsoft Management Console snap-in displays.

When you are implementing a custom service, the value of this property must be identical to the name recorded for the service in the ServiceName property of the corresponding ServiceInstaller class. In code, the ServiceName is usually set in the main() function of the executable.

When you reset the ServiceName property, the method that sets the property sets this instance's DisplayName to an empty string ("").

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft