ServiceController.DependentServices Property

Definition

Gets the set of services that depends on the service associated with this ServiceController instance.

C#
public System.ServiceProcess.ServiceController[] DependentServices { get; }
C#
[System.ServiceProcess.ServiceProcessDescription("SPDependentServices")]
public System.ServiceProcess.ServiceController[] DependentServices { get; }

Property Value

An array of ServiceController instances, each of which is associated with a service that depends on this service.

Attributes

Exceptions

An error occurred when accessing a system API.

The service was not found.

Examples

The following example uses the ServiceController class to display the set of services that are dependent on the Event Log service.

C#

ServiceController sc =  new ServiceController("Event Log");
ServiceController[] scServices = sc.DependentServices;

// Display the list of services dependent on the Event Log service.
if (scServices.Length == 0)
{
   Console.WriteLine("There are no services dependent on {0}",
                      sc.ServiceName);
}
else
{
   Console.WriteLine("Services dependent on {0}:",
                      sc.ServiceName);

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

Remarks

The DependentServices array represents the services that the system stops if your application calls Stop for this service.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)