Creates a block within which an OperationContext object is in scope.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Thetype exposes the following members.
|OperationContextScope(IContextChannel)||Initializes a new instance of the class that uses the specified IContextChannel to create a new OperationContext for the scope.|
|OperationContextScope(OperationContext)||Initializes a new instance of the class to create a scope for the specified OperationContext object.|
|Dispose||Restores the original OperationContext to the active context and recycles the object.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
Use the class to create a scope for a specific OperationContext object or a scope for a new OperationContext object using a specified IContextChannel object. An can be used in a Windows Communication Foundation (WCF) service or WCF client application.
Once the object has established the current operation context, you can use the OperationContext to:
Access and modify incoming and outgoing message headers and other properties.
Access the runtime, including dispatchers, the host, channel, and extensions.
Access other types of contexts, such as security, instance, and request contexts.
When an is created, the current OperationContext is stored and the new OperationContext becomes the one returned by the Current property. When the is disposed, the original OperationContext is restored.
Do not use the asynchronous “await” pattern within a OperationContextScope block. When the continuation occurs, it may run on a different thread and OperationContextScope is thread specific. If you need to call “await” for an async call, use it outside of the OperationContextScope block.
.NET FrameworkSupported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.