Export (0) Print
Expand All

SPServiceInstance Class

Represents a single instance of a service that runs on a server.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

[GuidAttribute("983C4B09-FBC0-4f4b-92BC-42FABF556ED5")]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPServiceInstance : SPPersistedUpgradableObject

The SPServiceInstance 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft