LocalMessageReceiver Constructor (String)

Silverlight

Initializes a new instance of the LocalMessageReceiver class and configures it with the specified name.

Namespace:  System.Windows.Messaging
Assembly:  System.Windows (in System.Windows.dll)

public LocalMessageReceiver(
	string receiverName
)

Parameters

receiverName
Type: System.String
The name of the receiver.

ExceptionCondition
ArgumentNullException

receiverName is null.

ArgumentException

receiverName is longer than 256 characters.

This constructor initializes the ReceiverName property to the specified value, and the NameScope property to Domain. The AllowedSenderDomains property remains null, which indicates that the receiver can receive messages only from senders on the same domain.

For more information, see Communication Between Local Silverlight-Based Applications.

The following code example demonstrates how to use this constructor.


// In the receiving application:
LocalMessageReceiver messageReceiver = new LocalMessageReceiver("receiver");
messageReceiver.MessageReceived += new 
    EventHandler<MessageReceivedEventArgs>(receiver_MessageReceived);
try
{
    messageReceiver.Listen();
}
catch (ListenFailedException)
{
    MessageBox.Show(
        "Cannot receive messages." + Environment.NewLine +
        "There is already a receiver with the name 'receiver'.",
        "LocalMessageReceiver", MessageBoxButton.OK);
}

// In the sending application:
LocalMessageSender messageSender = new LocalMessageSender("receiver");
messageSender.SendCompleted += new 
    EventHandler<SendCompletedEventArgs>(sender_SendCompleted);


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: