This documentation is archived and is not being maintained.

ServiceController.ServicesDependedOn Property

The set of services that this service depends on.

Namespace: System.ServiceProcess
Assembly: System.ServiceProcess (in system.serviceprocess.dll)

'Declaration
Public ReadOnly Property ServicesDependedOn As ServiceController()
'Usage
Dim instance As ServiceController
Dim value As ServiceController()

value = instance.ServicesDependedOn

/** @property */
public ServiceController[] get_ServicesDependedOn ()

public function get ServicesDependedOn () : ServiceController[]

Property Value

An array of ServiceController instances, each of which is associated with a service that must be running for this service to run.

Exception typeCondition

Win32Exception

An error occurred when accessing a system API.

If any service in the ServicesDependedOn array is not running, you will not be able to start this service.

The following example uses the ServiceController class to display the set of services that the Messenger service is dependent on.


Dim sc As New ServiceController("Messenger")
Dim scServices As ServiceController() = sc.ServicesDependedOn

' Display the services that the Messenger service is dependent on.
If scServices.Length = 0 Then
   Console.WriteLine("{0} service is not dependent on any other services.", sc.ServiceName)
Else
   Console.WriteLine("{0} service is dependent on the following:", sc.ServiceName)
   
   Dim scTemp As ServiceController
   For Each scTemp In  scServices
      Console.WriteLine(" {0}", scTemp.DisplayName)
   Next scTemp
End If


ServiceController sc = new ServiceController("Messenger");
ServiceController scServices[] = sc.get_ServicesDependedOn();
// Display the services that the Messenger service is dependent on.
if (scServices.length == 0) {
    Console.WriteLine("{0} service is not dependent on any other "
        + "services.", sc.get_ServiceName());
}
else {
    Console.WriteLine("{0} service is dependent on the following:",
        sc.get_ServiceName());
    ServiceController scTemp = null;
    for (int iCtr = 0; iCtr < scServices.get_Length(); iCtr++) {
        scTemp = scServices[iCtr];
        Console.WriteLine(" {0}", scTemp.get_DisplayName());
    }
}

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: