Export (0) Print
Expand All

ServiceController.ServicesDependedOn Property

The set of services that this service depends on.

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

public ServiceController[] ServicesDependedOn { get; }
/** @property */
public ServiceController[] get_ServicesDependedOn ()

public function get ServicesDependedOn () : ServiceController[]

Not applicable.

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.

ServiceController sc = new ServiceController("Messenger");
ServiceController[] scServices= sc.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.ServiceName);
}
else 
{
   Console.WriteLine("{0} service is dependent on the following:",
                      sc.ServiceName);

   foreach (ServiceController scTemp in scServices)
   {
      Console.WriteLine(" {0}", scTemp.DisplayName);
   }
}

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 Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft