This topic has not yet been rated - Rate this topic

InstanceContext Class

Represents the context information for a service instance.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public sealed class InstanceContext : CommunicationObject, 
	IExtensibleObject<InstanceContext>

The InstanceContext type exposes the following members.

  NameDescription
Public methodSupported in .NET for Windows Store appsInstanceContext(Object)Initializes a new instance of the InstanceContext class for a specified object that implements the service instance.
Public methodInstanceContext(ServiceHostBase)Initializes a new instance of the InstanceContext class for a service hosted by a specified host.
Public methodInstanceContext(ServiceHostBase, Object)Initializes a new instance of the InstanceContext class for a specified object that implements the service instance and is hosted by a specified host.
Top
  NameDescription
Public propertyExtensionsGets the extension collection, if any, associated with the service instance.
Public propertyHostGets the host for the service instance.
Public propertyIncomingChannelsGets the sessionful channels that are incoming to the service instance.
Public propertyManualFlowControlLimitGets or sets a limit on the number of messages that can be processed by the instance context.
Public propertyOutgoingChannelsGets the sessionful channels that are outgoing from the service instance.
Public propertySupported in .NET for Windows Store appsStateGets a value that indicates the current state of the communication object. (Inherited from CommunicationObject.)
Public propertySupported in .NET for Windows Store appsSynchronizationContextGets or sets the context used for thread synchronization with the current instance context.
Top
  NameDescription
Public methodSupported in .NET for Windows Store appsAbortCauses a communication object to transition immediately from its current state into the closing state. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsBeginClose(AsyncCallback, Object)Begins an asynchronous operation to close a communication object. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsBeginClose(TimeSpan, AsyncCallback, Object)Begins an asynchronous operation to close a communication object with a specified timeout. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsBeginOpen(AsyncCallback, Object)Begins an asynchronous operation to open a communication object. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsBeginOpen(TimeSpan, AsyncCallback, Object)Begins an asynchronous operation to open a communication object within a specified interval of time. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsClose()Causes a communication object to transition from its current state into the closed state. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsClose(TimeSpan)Causes a communication object to transition from its current state into the closed state within a specified interval of time. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsEndCloseCompletes an asynchronous operation to close a communication object. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsEndOpenCompletes an asynchronous operation to open a communication object. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodSupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetServiceInstance()Returns the instance of the service for the instance context.
Public methodSupported in .NET for Windows Store appsGetServiceInstance(Message)Returns the instance of the service for the instance context in response to an incoming message.
Public methodSupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIncrementManualFlowControlLimitIncreases the number of messages that can be processed by the service instance.
Public methodSupported in .NET for Windows Store appsOpen()Causes a communication object to transition from the created state into the opened state. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsOpen(TimeSpan)Causes a communication object to transition from the created state into the opened state within a specified interval of time. (Inherited from CommunicationObject.)
Public methodReleaseServiceInstanceReleases the service instance.
Protected methodThrowIfDisposedThrows an exception if the communication object is disposed. (Inherited from CommunicationObject.)
Protected methodThrowIfDisposedOrImmutableThrows an exception if the communication object the State property is not set to the Created state. (Inherited from CommunicationObject.)
Protected methodThrowIfDisposedOrNotOpenThrows an exception if the communication object is not in the Opened state. (Inherited from CommunicationObject.)
Public methodSupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public eventSupported in .NET for Windows Store appsClosedOccurs when a communication object transitions into the closed state. (Inherited from CommunicationObject.)
Public eventSupported in .NET for Windows Store appsClosingOccurs when a communication object transitions into the closing state. (Inherited from CommunicationObject.)
Public eventSupported in .NET for Windows Store appsFaultedOccurs when a communication object transitions into the faulted state. (Inherited from CommunicationObject.)
Public eventSupported in .NET for Windows Store appsOpenedOccurs when a communication object transitions into the opened state. (Inherited from CommunicationObject.)
Public eventSupported in .NET for Windows Store appsOpeningOccurs when a communication object transitions into the opening state. (Inherited from CommunicationObject.)
Top

The following code illustrates how to obtain instance context information from a service:

string info = "";

OperationContext operationContext = OperationContext.Current;
InstanceContext instanceContext = operationContext.InstanceContext;

info += "    " + "State: " + instanceContext.State.ToString() + "\n";
info += "    " + "ManualFlowControlLimit: " + instanceContext.ManualFlowControlLimit.ToString() + "\n";
info += "    " + "HashCode: " + instanceContext.GetHashCode().ToString() + "\n";

return info;

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Store apps

Supported in: Windows 8

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.