This topic has not yet been rated - Rate this topic

MsmqTransportBindingElement Class

Represents the binding element used to specify the queuing communication properties for a Windows Communication Foundation (WCF) service that uses the native Message Queuing (MSMQ) protocol.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public final class MsmqTransportBindingElement extends MsmqBindingElementBase

The MsmqTransportBindingElement enables the user to set the properties of the queued communication channel. The queued communication channel uses Message Queuing for its transport.

This binding element is the default binding element used by the Message Queuing standard binding (NetMsmqBinding).

string queueName = @".\private$\ServiceModelSamples";

if (!MessageQueue.Exists(queueName))
    MessageQueue.Create(queueName, true);

using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService)))
{
    BinaryMessageEncodingBindingElement encodingBindingElement = new BinaryMessageEncodingBindingElement();
    MsmqTransportBindingElement transportBindingElement = new MsmqTransportBindingElement();
    CustomBinding binding = new CustomBinding(encodingBindingElement, transportBindingElement);

    serviceHost.AddServiceEndpoint(
        typeof(IQueueCalculator),
        binding,
        "net.msmq://localhost/private/ServiceModelSamples");

    serviceHost.Open();

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

    // Close the ServiceHost to shutdown the service.
    serviceHost.Close();
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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.