Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CommunicationState Enumeration

Defines the states in which an ICommunicationObject can exist.

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

public enum CommunicationState

Member nameDescription
Supported by Portable Class LibrarySupported in .NET for Windows Store appsClosedIndicates that the communication object has been closed and is no longer usable.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsClosingIndicates that the communication object is transitioning to the Closed state.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsCreatedIndicates that the communication object has been instantiated and is configurable, but not yet open or ready for use.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsFaultedIndicates that the communication object has encountered an error or fault from which it cannot recover and from which it is no longer usable.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsOpenedIndicates that the communication object is now open and ready to be used.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsOpeningIndicates that the communication object is being transitioned from the Created state to the Opened state.

This enumeration defines the states that are valid for all communication objects in the system, including channels, listeners, factories, dispatchers, and service hosts.

The methods that manage transitions between these states and the events that can be associated with them are defined in the ICommunicationObject interface. The state of an object can be obtained using the State property.

There are four main states and two transient states that a communication object can occupy. The main states are:

  • Created

  • Opened

  • Closed

  • Faulted

The two transitory states that a communication object can occupy when transitioning between these main states are:

  • Opening

  • Closing

The communication object can be configured in the Created state. For example, its properties can be changed, and its events can be registered. No input or output can occur in this state. So messages, for example, cannot be sent or received from a channel in this state.

The Opening is a temporary state that the communication object enters when the Open method is invoked. Unless otherwise noted on derived classes, objects in the opening state cannot be configured. This transition state can only be entered from the Created state.

Objects transition to the Opened state when the open process completes. This transition to the Opened state is only valid from the Opening state. Unless otherwise noted on derived classes, the configuration of the object is now disabled. At this point, the object is fully usable for message transfers.

The Closing is a temporary state that the object enters when the Close method is invoked for a graceful shutdown or the object is aborted. At this point, the object becomes (if not already) unusable. This transition is valid from any state except the Closed state.

The Closed state is equivalent to being disposed and the configuration of the object can still be inspected.

The Faulted state is used to indicate that the object has transitioned to a state where it can no longer be used. There are two primary scenarios where this can happen:

  • If the Open method fails for any reason, the object transitions to the faulted state.

  • If a session-based channel detects an error that it cannot recover from, it transitions to the faulted state. This can happen for instance if there is a protocol error (that is, it receives a protocol message at an invalid time) or if the remote endpoint aborts the session.

An object in the Faulted state is not closed and may be holding resources. The Abort method should be used to close an object that has faulted. If Close is called on an object in the Faulted state, a CommunicationObjectFaultedException is thrown because the object cannot be gracefully closed.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 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.

Show:
© 2014 Microsoft