Share via


SPServiceInstance class

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

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
        Microsoft.SharePoint.Administration.SPServiceInstance
          

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
<GuidAttribute("983C4B09-FBC0-4f4b-92BC-42FABF556ED5")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPServiceInstance _
    Inherits SPPersistedUpgradableObject
'Usage
Dim instance As SPServiceInstance
[GuidAttribute("983C4B09-FBC0-4f4b-92BC-42FABF556ED5")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPServiceInstance : SPPersistedUpgradableObject

Remarks

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.

Thread safety

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

See also

Reference

SPServiceInstance members

Microsoft.SharePoint.Administration namespace

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
        Microsoft.SharePoint.Administration.SPServiceInstance
          Microsoft.SharePoint.Administration.SPDatabaseServiceInstance
          Microsoft.SharePoint.Administration.SPIisWebServiceInstance
          Microsoft.SharePoint.Administration.SPIncomingEmailServiceInstance
          Microsoft.SharePoint.Administration.SPOutboundMailServiceInstance
          Microsoft.SharePoint.Administration.SPRequestManagementServiceInstance
          Microsoft.SharePoint.Administration.SPUsageServiceInstance
          Microsoft.SharePoint.Administration.SPWebServiceInstance
          Microsoft.SharePoint.Administration.SPWindowsServiceInstance