This documentation is archived and is not being maintained.

WorkflowRuntime.GetService Method (Type)

Retrieves a service of the specified Type from the workflow runtime engine.

Namespace:  System.Workflow.Runtime
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)

public Object GetService(
	Type serviceType


Type: System.Type

The Type of the service to retrieve.

Return Value

Type: System.Object
An object that represents a service of the specified Type.




serviceType is a null reference (Nothing in Visual Basic)


The WorkflowRuntime has already been disposed of.


More than one service of type serviceType was found.

GetService throws an InvalidOperationException if more than one service exists for the specified Type. Therefore, you should use one of the overloaded methods of GetAllServices if it is possible that multiple services of the specified type may be present in the WorkflowRuntime. For example, the workflow runtime engine may have multiple tracking services, if you request a tracking service by specifying the TrackingService base class, it is possible that an exception will be thrown.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0