Export (0) Print
Expand All

ServiceInstaller.ServiceName Property

Indicates the name used by the system to identify this service. This property must be identical to the ServiceBase.ServiceName of the service you want to install.

[Visual Basic]
Public Property ServiceName As String
[C#]
public string ServiceName {get; set;}
[C++]
public: __property String* get_ServiceName();
public: __property void set_ServiceName(String*);
[JScript]
public function get ServiceName() : String;
public function set ServiceName(String);

Property Value

The name of the service to be installed. This value must be set before the install utility attempts to install the service.

Exceptions

Exception Type Condition
ArgumentException The ServiceName property is invalid.

Remarks

It is crucial that the ServiceName be identical to the ServiceBase.ServiceName of the class you derived from ServiceBase. Normally, the value of the ServiceBase.ServiceName property for the service is set within the Main() function of the service application's executable. The Service Control Manager uses the ServiceInstaller.ServiceName property to locate the service within this executable.

When you set the ServiceName of the service installer, the Source of the associated event log is set to the same value. This allows the service to automatically log service commands (such as Start and Stop) calls to the Application log on the computer.

Note   If a source by the same name already exists on the computer, but in a log other than the Application log, an exception will be thrown. If the source exists and is associated with the Application log, that source is used to report command calls to the service, and no exception is thrown.
The ServiceName cannot be a null reference (Nothing in Visual Basic) or have zero length. Its maximum size is 256 characters. It also cannot contain forward or backward slashes, '/' or '\', or characters from the ASCII character set with value less than decimal value 32.

Requirements

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

ServiceInstaller Class | ServiceInstaller Members | System.ServiceProcess Namespace | ServiceBase.ServiceName | DisplayName

Show:
© 2015 Microsoft