WorkflowRuntime.AddService(Object) Method

Definition

Adds the specified service to the workflow run-time engine.

public:
 void AddService(System::Object ^ service);
public void AddService(object service);
member this.AddService : obj -> unit
Public Sub AddService (service As Object)

Parameters

service
Object

An object that represents the service to add.

Exceptions

service is a null reference (Nothing in Visual Basic).

service is already registered with the workflow run-time engine.

-or-

service is a core service and the workflow run-time engine is already running (IsStarted is true).

Remarks

You can configure the workflow run-time engine by adding core services. Core services are those that derive from any of the following service base classes: the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, the WorkflowPersistenceService class, and the TrackingService class. Core services can only be added when the workflow run-time engine is not running; that is, when IsStarted is false. The WorkflowRuntime can also be used as a storage container for other services that can be used by other workflows or by applications running on a host. If you add a non-core service that derives from the WorkflowRuntimeService class after the workflow run-time engine has been started, AddService calls the Start method implemented by that service.

Note

AddService enforces the restriction that no two services of the same Type can be added to the WorkflowRuntime. However, you can add multiple services that derive from the same base class. There can be only one service derived from each of the following service base classes in the WorkflowRuntime: the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, and the WorkflowPersistenceService class. If you add multiple services derived from one of these classes, for example two persistence services, StartRuntime throws an InvalidOperationException.

Applies to