This documentation is archived and is not being maintained.

ReliableSessionBindingElement Class

Represents the binding element that can produce the sending and receiving channels required for a reliable session between endpoints.

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

public ref class ReliableSessionBindingElement sealed : public BindingElement, 

Provides sessions and optionally provides ordered message delivery. This implemented session can cross SOAP and transport intermediaries.

Each binding element represents a processing step when sending or receiving messages. At runtime, binding elements create the channel factories and listeners that are necessary to build outgoing and incoming channel stacks required to send and receive messages. The ReliableSessionBindingElement provides an optional layer in the stack that can establish a reliable session between endpoints and configure the behavior of this session.

The ReliableSessionBindingElement is provided on the standard bindings in the following table.








On (required)

The ReliableSessionBindingElement can be added to any custom binding. This is done using the following configuration elements.

        <binding configurationName=”ReliabilityHTTP”>

The following sample code demonstrates how to use ReliableSessionBindingElement in code.

Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address. 
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
    // Create a custom binding that contains two binding elements.
    ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement();
    reliableSession.Ordered = true;

    HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
    httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
    httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

    CustomBinding binding = new CustomBinding(reliableSession, httpTransport);

    // Add an endpoint using that binding.
    serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, "");

    // Add a MEX endpoint.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples");

    // Open the ServiceHostBase to create listeners and start listening for messages.

    // The service can now be accessed.
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");

    // Close the ServiceHostBase to shutdown the service.


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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0