Export (0) Print
Expand All

MessageQueue.Send Method (Object, String)

Sends an object to the non-transactional queue referenced by this MessageQueue and specifies a label for the message.

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

'Declaration
Public Sub Send ( _
	obj As Object, _
	label As String _
)

Parameters

obj
Type: System.Object

The object to send to the queue.

label
Type: System.String

The label of the message.

ExceptionCondition
ArgumentNullException

The label parameter is Nothing.

MessageQueueException

The Path property has not been set.

-or-

An error occurred when accessing a Message Queuing method.

Use this overload to send a message that contains the obj parameter to the queue referenced by the MessageQueue. With this overload, you can specify the string label that identifies the message. The object you send to the queue can be a Message, a structure, a data object, or any managed object. If you send any object other than a Message, the object is serialized and inserted into the body of the message.

The message label is distinct from the message queue label, but both are application-dependent and have no inherit meaning to Message Queuing.

If you use this overload to send a message to a transactional queue, the message will be sent to the dead-letter queue. If you want the message to be part of a transaction that contains other messages, use an overload that takes a MessageQueueTransaction or MessageQueueTransactionType as a parameter.

The Path property for this MessageQueue instance must be specified before you send the message. If you do not set the Formatter property before calling Send(Object), the formatter defaults to the XmlMessageFormatter.

The DefaultPropertiesToSend property applies to any object other than a Message. If you specify, for example, a label or a priority using the DefaultPropertiesToSend member, these values apply to any message that contains an object that is not of type Message when your application sends it to the queue. When sending a Message, the property values set for the Message take precedence over DefaultPropertiesToSend and the message's Message.Formatter property takes precedence over the queue's MessageQueue.Formatter property.

The following table shows whether this method is available in various Workgroup modes.

Workgroup mode

Available

Local computer

Yes

Local computer and direct format name

Yes

Remote computer

No

Remote computer and direct format name

Yes

The following code example demonstrates the use of Send(Object, String).

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft