DispatchRuntime DispatchRuntime DispatchRuntime DispatchRuntime Class


Exposes properties that can be used to modify default service behavior as well as attach custom objects that can modify how incoming messages are transformed into objects and dispatched to operations. This class cannot be inherited.

public ref class DispatchRuntime sealed
public sealed class DispatchRuntime
type DispatchRuntime = class
Public NotInheritable Class DispatchRuntime


Use the DispatchRuntime class either to modify the default behavior of a service or individual endpoint, or to insert objects that implement custom modifications to one or both of the following service processes:

  1. The transformation of incoming messages into objects and releasing those objects as method invocations on a service object.

  2. The transformation of objects received from the response to a service operation invocation into outbound messages.

In Windows Communication Foundation (WCF), the channel and endpoint dispatchers are the service components responsible for accepting new channels, receiving messages, method dispatch and invocation, and response processing. Each endpoint exposed by a ServiceHost object has one endpoint dispatcher and an associated channel dispatcher; in addition, each client that participates in duplex communication also has an endpoint dispatcher and channel dispatcher for each callback endpoint.

The DispatchRuntime enables you to intercept and extend the channel or endpoint dispatcher for all messages across a particular contract, even when a message is not recognized. When a message arrives that does not match any messages declared in the contract it is dispatched to the operation that was returned by the UnhandledDispatchOperation property. To intercept or extend across all messages for a particular operation, see the DispatchOperation class.

There are four main areas of dispatcher extensibility exposed by the DispatchRuntime class:

  1. Dispatch components use the properties of the DispatchRuntime and those of the associated channel dispatcher returned by the ChannelDispatcher property to customize how the channel dispatcher accepts and closes channels. This category includes the ChannelInitializers and InputSessionShutdownHandlers properties.

  2. Message components are customized for each message processed. This category includes the MessageInspectors, OperationSelector, Operations, and the ErrorHandlers properties.

  3. Instance components customize the creation, lifetime, and disposal of instances of the service type. For more information about service object lifetimes, see the InstanceContextMode property. This category includes the InstanceContextInitializers and the InstanceProvider properties.

  4. Security-related components can use the following properties:

Typically custom extension objects are assigned to a DispatchRuntime property or inserted into a collection by a service behavior (an object that implements IServiceBehavior), a contract behavior (an object that implements IContractBehavior), or an endpoint behavior (an object that implements IEndpointBehavior). Then the installing behavior object is added to the appropriate collection of behaviors either programmatically or by implementing a custom BehaviorExtensionElement object to enable the behavior to be inserted using an application configuration file.


AutomaticInputSessionShutdown AutomaticInputSessionShutdown AutomaticInputSessionShutdown AutomaticInputSessionShutdown

Gets or sets a value that specifies whether the service closes an input session when the client closes an output session.

CallbackClientRuntime CallbackClientRuntime CallbackClientRuntime CallbackClientRuntime

Gets the ClientRuntime object that represents the installation point for extensions to Windows Communication Foundation (WCF) for outbound calls to a duplex callback endpoint.

ChannelDispatcher ChannelDispatcher ChannelDispatcher ChannelDispatcher

Gets the ChannelDispatcher for this dispatch run-time object.

ConcurrencyMode ConcurrencyMode ConcurrencyMode ConcurrencyMode

Gets or sets whether an instance of a service processes messages sequentially or concurrently.

EndpointDispatcher EndpointDispatcher EndpointDispatcher EndpointDispatcher

Gets the EndpointDispatcher for this dispatch runtime.

EnsureOrderedDispatch EnsureOrderedDispatch EnsureOrderedDispatch EnsureOrderedDispatch

Gets a value that indicates whether messages are to be dispatched in the order they were sent.

ExternalAuthorizationPolicies ExternalAuthorizationPolicies ExternalAuthorizationPolicies ExternalAuthorizationPolicies

Gets or sets the external authorization policies that define a set of rules for authorizing a user, given a set of claims.

IgnoreTransactionMessageProperty IgnoreTransactionMessageProperty IgnoreTransactionMessageProperty IgnoreTransactionMessageProperty

Gets or sets whether to ignore the TransactionMessageProperty.

ImpersonateCallerForAllOperations ImpersonateCallerForAllOperations ImpersonateCallerForAllOperations ImpersonateCallerForAllOperations

Gets or sets a value that controls whether the service attempts to impersonate using the credentials provided by the incoming message.

ImpersonateOnSerializingReply ImpersonateOnSerializingReply ImpersonateOnSerializingReply ImpersonateOnSerializingReply

Gets a value that indicates whether impersonation is used on serializing reply operation.

InputSessionShutdownHandlers InputSessionShutdownHandlers InputSessionShutdownHandlers InputSessionShutdownHandlers

Gets a collection of IInputSessionShutdown objects that can be used to add a custom handler to control how input sessions are closed.

InstanceContextInitializers InstanceContextInitializers InstanceContextInitializers InstanceContextInitializers

Gets a collection of IInstanceContextInitializer objects that can be used to inspect or modify an InstanceContext object when it is first created.

InstanceContextProvider InstanceContextProvider InstanceContextProvider InstanceContextProvider

Gets or sets the IInstanceContextProvider to be used by the DispatchRuntime.

InstanceProvider InstanceProvider InstanceProvider InstanceProvider

Gets or sets an IInstanceProvider object that you can use to control the creation and destruction of service objects.

MessageAuthenticationAuditLevel MessageAuthenticationAuditLevel MessageAuthenticationAuditLevel MessageAuthenticationAuditLevel

Gets or sets a value that specifies whether successful message authentication events are written to the event log specified by SecurityAuditLogLocation.

MessageInspectors MessageInspectors MessageInspectors MessageInspectors

Gets a collection of IDispatchMessageInspector objects that can be used to attach a custom message inspector for all incoming and outgoing messages across the endpoint.

Operations Operations Operations Operations

Gets a collection of DispatchOperation objects that can be used to control the execution behavior of a particular operation.

OperationSelector OperationSelector OperationSelector OperationSelector

Gets or sets the IDispatchOperationSelector object that controls the selection of a destination DispatchOperation for a particular message.

PreserveMessage PreserveMessage PreserveMessage PreserveMessage

Gets or sets whether the message is preserved.

PrincipalPermissionMode PrincipalPermissionMode PrincipalPermissionMode PrincipalPermissionMode

Gets or sets a value that specifies how the CurrentPrincipal property is set.

ReleaseServiceInstanceOnTransactionComplete ReleaseServiceInstanceOnTransactionComplete ReleaseServiceInstanceOnTransactionComplete ReleaseServiceInstanceOnTransactionComplete

Gets or sets a value that specifies whether the service object is recycled after the transaction successfully completes.

RoleProvider RoleProvider RoleProvider RoleProvider

Gets or sets the custom RoleProvider that is used by the DispatchRuntime.

SecurityAuditLogLocation SecurityAuditLogLocation SecurityAuditLogLocation SecurityAuditLogLocation

Gets or sets the location of the audit log.

ServiceAuthenticationManager ServiceAuthenticationManager ServiceAuthenticationManager ServiceAuthenticationManager

Gets or sets the object that manages an authentication process for service operations.

ServiceAuthorizationAuditLevel ServiceAuthorizationAuditLevel ServiceAuthorizationAuditLevel ServiceAuthorizationAuditLevel

Gets or sets a value that controls what service authorization events are audited.

ServiceAuthorizationManager ServiceAuthorizationManager ServiceAuthorizationManager ServiceAuthorizationManager

Gets the ServiceAuthorizationManager that provides authorization checking for the DispatchRuntime.

SingletonInstanceContext SingletonInstanceContext SingletonInstanceContext SingletonInstanceContext

Gets or sets the singleton IInstanceContextProvider to be used by the DispatchRuntime.

SuppressAuditFailure SuppressAuditFailure SuppressAuditFailure SuppressAuditFailure

Gets or sets a value that specifies whether to suppress non-critical exceptions that occur during the logging process.

SynchronizationContext SynchronizationContext SynchronizationContext SynchronizationContext

Gets or sets the synchronization context that is used to invoke the service operations.

TransactionAutoCompleteOnSessionClose TransactionAutoCompleteOnSessionClose TransactionAutoCompleteOnSessionClose TransactionAutoCompleteOnSessionClose

Gets or sets a value that specifies whether to automatically complete the current transaction when the session closes.

Type Type Type Type

Gets or sets the contract type.

UnhandledDispatchOperation UnhandledDispatchOperation UnhandledDispatchOperation UnhandledDispatchOperation

Gets or sets the operation to which unrecognized messages are dispatched.

ValidateMustUnderstand ValidateMustUnderstand ValidateMustUnderstand ValidateMustUnderstand

Gets or sets the value of ValidateMustUnderstand.


Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to