ServiceController.ServicesDependedOn Property

Definition

The set of services that this service depends on.

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

Property Value

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

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 the Messenger service is dependent on.

C#
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);
   }
}

Remarks

If any service in the ServicesDependedOn array is not running, you will not be able to start 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)