ServiceBase.ServiceName Property

Gets or sets the short name used to identify the service to the system.

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

[TypeConverterAttribute("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] 
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 of the service.

Exception typeCondition

InvalidOperationException

The service has already been started. The ServiceName property cannot be changed once the service has started.

ArgumentException

The ServiceName property is invalid.

The ServiceName identifies the service to the Service Control Manager. The value of this property must be identical to the name recorded for the service in the ServiceInstaller.ServiceName property of the corresponding installer class. In code, the ServiceName of the service is usually set in the main() function of the executable.

The ServiceName is also used to specify the EventLog.Source associated with the EventLog property. This EventLog is an instance that writes service command information to the Application log.

The ServiceName, which supplies the source string for the event log, must be set before the service writes to the event log. Trying to access the event log before the source name is set causes an exception to be thrown.

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: