LocalMessageReceiver Class
Represents the receiving end of a local messaging channel between two Silverlight-based applications.
Namespace: System.Windows.Messaging
Assembly: System.Windows (in System.Windows.dll)
The LocalMessageReceiver type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | LocalMessageReceiver(String) | Initializes a new instance of the LocalMessageReceiver class and configures it with the specified name. |
![]() | LocalMessageReceiver(String, ReceiverNameScope, IEnumerable<String>) | Initializes a new instance of the LocalMessageReceiver class and configures it with the specified name, namescope requirement, and allowed sender domains. |
| Name | Description | |
|---|---|---|
![]() | AllowedSenderDomains | Gets the domains that the receiver can receive messages from. |
![]() | DisableSenderTrustCheck | Gets or sets a value that indicates whether the receiver can receive messages from a sender with a different Protected Mode setting. |
![]() | NameScope | Gets a value that indicates whether the ReceiverName is scoped to the global namescope or to the receiver's specific domain. |
![]() | ReceiverName | Gets the name of the receiver. |
| Name | Description | |
|---|---|---|
![]() | Dispose | Stops the receiver from receiving messages and releases all resources used by the receiver. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Listen | Starts listening for messages from a LocalMessageSender. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
A LocalMessageReceiver object can receive messages from a LocalMessageSender object in a different Silverlight-based application running on the same computer. For information about using these classes, see Communication Between Local Silverlight-Based Applications.
The following code example demonstrates how to use this class. This example is part of a larger example available in How to: Implement Communication Between Local Silverlight-Based Applications.
using System; using System.Windows.Controls; using System.Windows.Messaging; namespace ReceivingApplication { public partial class Receiver : UserControl { public Receiver() { InitializeComponent(); LocalMessageReceiver messageReceiver = new LocalMessageReceiver("receiver", ReceiverNameScope.Global, LocalMessageReceiver.AnyDomain); messageReceiver.MessageReceived += messageReceiver_MessageReceived; try { messageReceiver.Listen(); } catch (ListenFailedException) { output.Text = "Cannot receive messages." + Environment.NewLine + "There is already a receiver with the name 'receiver'."; } } private void messageReceiver_MessageReceived( object sender, MessageReceivedEventArgs e) { e.Response = "response to " + e.Message; output.Text = "Message: " + e.Message + Environment.NewLine + "NameScope: " + e.NameScope + Environment.NewLine + "ReceiverName: " + e.ReceiverName + Environment.NewLine + "SenderDomain: " + e.SenderDomain + Environment.NewLine + "Response: " + e.Response; } } }
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
