ContextBindingElement Class

 

Provides a protection level and an exchange mechanism as part of the context of a binding element and the functionality to build the channel listeners and factories.

Namespace:   System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

System.Object
  System.ServiceModel.Channels.BindingElement
    System.ServiceModel.Channels.ContextBindingElement

public class ContextBindingElement : BindingElement, IPolicyExportExtension, 
	IContextBindingElement

NameDescription
System_CAPS_pubmethodContextBindingElement()

Initializes a new instance of the ContextBindingElement class.

System_CAPS_pubmethodContextBindingElement(ProtectionLevel)

Initializes a new instance of the ContextBindingElement class with a specified level of protection.

System_CAPS_pubmethodContextBindingElement(ProtectionLevel, ContextExchangeMechanism)

Initializes a new instance of the ContextBindingElement class with a specified level of protection and exchange mechanism.

System_CAPS_pubmethodContextBindingElement(ProtectionLevel, ContextExchangeMechanism, Uri)

Initializes a new instance of the ContextBindingElement class with the specified protection level, context exchange mechanism, and client callback address.

System_CAPS_pubmethodContextBindingElement(ProtectionLevel, ContextExchangeMechanism, Uri, Boolean)

Initializes a new instance of the ContextBindingElement class with the specified protection level, context exchange mechanism, client callback address, and a value that specifies whether context management is enabled.

NameDescription
System_CAPS_pubpropertyClientCallbackAddress

Gets or sets the client callback address for the binding element.

System_CAPS_pubpropertyContextExchangeMechanism

Gets or sets the exchange mechanism used to communicate context for the binding element.

System_CAPS_pubpropertyContextManagementEnabled

Gets or sets a value that specifies whether context management is enabled.

System_CAPS_pubpropertyProtectionLevel

Gets or sets the level of protection for the binding element from the context.

NameDescription
System_CAPS_pubmethodBuildChannelFactory<TChannel>(BindingContext)

Builds the channel factory stack on the client that creates a specified type of channel for a specified context.(Overrides BindingElement.BuildChannelFactory<TChannel>(BindingContext).)

System_CAPS_pubmethodBuildChannelListener<TChannel>(BindingContext)

Builds the channel listener stack on the client that accepts a specified type of channel for a specified context.(Overrides BindingElement.BuildChannelListener<TChannel>(BindingContext).)

System_CAPS_pubmethodCanBuildChannelFactory<TChannel>(BindingContext)

Returns a value that indicates whether the current binding element can build a factory for a specified type of channel and context.(Overrides BindingElement.CanBuildChannelFactory<TChannel>(BindingContext).)

System_CAPS_pubmethodCanBuildChannelListener<TChannel>(BindingContext)

Returns a value that indicates whether the current binding can build a listener for a specified type of channel and context.(Overrides BindingElement.CanBuildChannelListener<TChannel>(BindingContext).)

System_CAPS_pubmethodClone()

Creates a new ContextBindingElement object initialized from the current one.(Overrides BindingElement.Clone().)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodExportPolicy(MetadataExporter, PolicyConversionContext)

Writes custom policy assertions into the context of the binding element.

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetProperty<T>(BindingContext)

Returns the typed object with the specified context from the appropriate layer in the channel stack.(Overrides BindingElement.GetProperty<T>(BindingContext).)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The ContextBindingElement allows the user to add an element to the binding of a service for managing its context exchange protocol. The ContextBindingElement is typically stacked on top of reliability, security, and transport binding elements. A ContextBindingElement does not require any configuration options and can create channel factories for IRequestChannel, IRequestSessionChannel, and IDuplexSessionChannel. It can also create channel listeners for IReplyChannel, IReplySessionChannel, and IDuplexSessionChannel. A context channel does not change the channel interface – the underlying channel stack must support the requested channel shape and session capability.

The channel listeners and factories are used to construct the part of the channel stacks used to process incoming and outgoing messages.

System_CAPS_noteNote

If a session-based binding is created with a ContextBindingElement and used with a contract that specifies SessionMode = NotAllowed, an InvalidOperationException is thrown when the channel is created with the following text: "Channel context management cannot be enabled or disabled after the channel is opened." You must set SessionMode to Allowed or Required or not use a session-based channel.

When creating a custom binding, it is recommended that you add the ContextBindingElement to the BindingElementCollection of the custom binding before adding any reliability and security binding elements, if present. If you do not, your service may throw a ProtocolException with the following message:

"Context channel received a message with context which does not match the current context cached at the channel. Ensure service does not change context after it was originally set or disable context management by setting channel property 'IContextManager.Enabled' to false."

.NET Framework
Available since 3.5

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: