Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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)
'Declaration
<ServiceProcessDescriptionAttribute("SPServiceName")> _
<SettingsBindableAttribute(True)> _
Public Property ServiceName As String

Property Value

Type: System.String
The name that identifies the service that this ServiceController instance references. The default is an empty string ("").
ExceptionCondition
ArgumentNullException

The ServiceName is Nothing.

ArgumentException

The syntax of the ServiceName property is invalid.

InvalidOperationException

The service was not found.

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 ("").

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.