OperationContextScope Constructor (IContextChannel)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Initializes a new instance of the OperationContextScope class that uses the specified IContextChannel to create a new OperationContext for the scope.

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

Syntax

'Declaration
Public Sub New ( _
    channel As IContextChannel _
)
public OperationContextScope(
    IContextChannel channel
)

Parameters

Remarks

Use the OperationContextScope constructor to create a new OperationContext for a client channel that can be used to add or modify outbound message headers, read incoming message headers, or access other run-time properties of the OperationContext.

The headers added to the OperationContext.IncomingMessageHeaders property of the newly created OperationContext apply only to the channel that was passed to the OperationContextScope constructor. If the user creates a new channel within its scope, then the headers are not applied to messages sent on the new channel.

Examples

The following example shows how to use the OperationContextScope to create a new context in a client application in order to add a custom header to the outgoing message.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.