Represents a single instance of a service that runs on a server.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
The class associates services with servers. Use the Service property to get the SPService object that contains the farm-wide settings that apply to the service that this instance implements. Use the Server property to get the SPServer object on which this instance is installed.
To return an SPServiceInstanceCollection object that represents the service instances that currently run on a server, use either the ServiceInstances property of the SPServer class, or the SPServiceInstanceCollection constructor. To return an SPServiceInstanceDependencyCollection object that represents the service instances that are dependent upon a service, use the Instances property of the SPService class.
Use an indexer to return a single service instance from the collection. For example, if the collection is assigned to a variable named myServiceInstances, use myServiceInstances[index] in C#, or myServiceInstances(index) in Visual Basic, where index is either the name or the GUID that identifies the service instance. The indexer only works with the name when all of the collection objects are of the same base type. However, a service instance collection will often contain derived classes, so only the GUID can safely be used to retrieve an object. Use the GetValue method of the SPPersistedObjectCollection<T> class to retrieve a service instance by name.