편집

다음을 통해 공유


NetMsmqBinding Constructors

Definition

Initializes a new instance of the NetMsmqBinding class.

Overloads

NetMsmqBinding()

Initializes a new instance of the NetMsmqBinding class.

NetMsmqBinding(NetMsmqSecurityMode)

Initializes a new instance of the NetMsmqBinding class using the specified security mode.

NetMsmqBinding(String)

Initializes a new instance of the NetMsmqBinding class from the settings of a specified configuration binding element.

NetMsmqBinding()

Initializes a new instance of the NetMsmqBinding class.

public:
 NetMsmqBinding();
public NetMsmqBinding ();
Public Sub New ()

Applies to

NetMsmqBinding(NetMsmqSecurityMode)

Initializes a new instance of the NetMsmqBinding class using the specified security mode.

public:
 NetMsmqBinding(System::ServiceModel::NetMsmqSecurityMode securityMode);
public NetMsmqBinding (System.ServiceModel.NetMsmqSecurityMode securityMode);
new System.ServiceModel.NetMsmqBinding : System.ServiceModel.NetMsmqSecurityMode -> System.ServiceModel.NetMsmqBinding
Public Sub New (securityMode As NetMsmqSecurityMode)

Parameters

securityMode
NetMsmqSecurityMode

The security mode with which to initialize the new instance.

Exceptions

The value is not one of the NetMsmqSecurityMode values.

Examples

The following code shows how to construct the NetMsmqBinding with a security mode.

NetMsmqBinding binding = new NetMsmqBinding(NetMsmqSecurityMode.Message);

Applies to

NetMsmqBinding(String)

Initializes a new instance of the NetMsmqBinding class from the settings of a specified configuration binding element.

public:
 NetMsmqBinding(System::String ^ configurationName);
public NetMsmqBinding (string configurationName);
new System.ServiceModel.NetMsmqBinding : string -> System.ServiceModel.NetMsmqBinding
Public Sub New (configurationName As String)

Parameters

configurationName
String

The value of the configurationName attribute that identifies the binding element whose settings are used to initialize the binding.

Examples

The following code shows how to instantiate an instance of NetMsmqBinding class.

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

// Create the transacted MSMQ queue if necessary.
if (!MessageQueue.Exists(queueName))
    MessageQueue.Create(queueName, true);

string baseAddress = "http://localhost:8000/queuedCalculator";
string endpointAddress = "net.msmq://localhost/private/ServiceModelSamples";

// Create a ServiceHost for the CalculatorService type.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), new Uri(baseAddress)))
{
    NetMsmqBinding binding = new NetMsmqBinding();
    serviceHost.AddServiceEndpoint(typeof(IQueueCalculator), binding, endpointAddress);

    // Add a MEX endpoint.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    serviceHost.Description.Behaviors.Add(smb);

    // Open the ServiceHostBase to create listeners and start listening for messages.
    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 ServiceHostBase to shutdown the service.
    serviceHost.Close();
}

Remarks

This name overwrites any configuration name at runtime that was assigned to the NetMsmqBinding element in a configuration file.

Applies to