WorkflowRuntime.RemoveService Method (Object)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Removes the specified service from the workflow run-time engine.

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

public void RemoveService(
	object service
)

Parameters

service
Type: System.Object

An object that represents the service to remove.

Exception Condition
ArgumentNullException

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

ObjectDisposedException

The WorkflowRuntime is already disposed of.

InvalidOperationException

The workflow run-time engine has started (IsStarted is true) and service is a core service.

- or -

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

You cannot remove a core service while the workflow run-time engine is running (IsStarted is true). Core services are services that derive from the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, the WorkflowPersistenceService class, or the TrackingService class. If service derives from the WorkflowRuntimeService class, RemoveService calls the Stop method implemented by service.

In the following example, a SqlWorkflowPersistenceService is added and removed from the WorkflowRuntime.

// Create a new workflow runtime
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Create a new instance of the out-of-box SqlWorkflowPersistenceService
SqlWorkflowPersistenceService persistenceService =
   new SqlWorkflowPersistenceService(
   "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;");
// Add the service to the runtime
workflowRuntime.AddService(persistenceService);
// Start the runtime
workflowRuntime.StartRuntime();
// Stop the runtime
workflowRuntime.StopRuntime();
// Remove the service from the runtime
workflowRuntime.RemoveService(persistenceService);

.NET Framework
Available since 3.0
Return to top
Show: