NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Message Constructor (Object)

Initializes a new instance of the Message class, serializing the object passed as an argument.

[Visual Basic]
Overloads Public Sub New( _
   ByVal body As Object _
)
[C#]
public Message(
   object body
);
[C++]
public: Message(
   Object* body
);
[JScript]
public function Message(
   body : Object
);

Parameters

body
The serializable body of the message.

Remarks

Use this overload to instantiate a Message object with the Body specified by the body parameter. The body parameter can be any serializable object, such as a text string, structure object, class instance, or embedded object.

The DefaultPropertiesToSend for a MessageQueue are overridden for any Message object that is sent to that queue. (These settings still apply to other objects sent to a queue using Send.)

Set the Formatter before sending the Message to a queue. If you want the body to be human-readable between the time that it is sent and received or peeked, use the SoapMessageFormatter. For messages with dataset bodies, use the DataSetMessageFormatter. The ActiveXMessageFormatter and BinaryMessageFormatter serialize the data into binary representation. The settings require the same formatter at both ends of the message processing. Binary formats are faster than XML format, but not human-readable during transit, and can't be read and fixed if a message becomes corrupted.

When a Message is created, the following read/write properties are set to initial values.

Property Initial Value
AcknowledgeType AcknowledgeType.None
AdministrationQueue a null reference (in Visual Basic Nothing)
AppSpecific 0
AttachSenderId true
AuthenticationProviderName Microsoft Base Cryptographic Provider, Ver. 1.0
AuthenticationProviderType CryptoProviderType.RSA_FULL
Body the body parameter
BodyStream Stream.null
BodyType 0
ConnectorType Guid.Empty
CorrelationId "" (empty string)
DestinationSymmetricKey A zero-length array of bytes
DigitalSignature A zero-length array of bytes
EncryptionAlgorithm EncryptionAlgorithm.RC2
Extension a zero-length array of bytes
Formatter SoapMessageFormatter
HashAlgorithm HashAlgorithm.MD5
Label "" (empty string)
Priority MessagePriority.Normal
Recoverable false
ResponseQueue a null reference (Nothing)
SenderCertificate a zero-length array of bytes
TimeToBeReceived Message.InfiniteTimeout
TimeToReachQueue Message.InfiniteTimeout
TransactionStatusQueue a null reference (Nothing)
UseAuthentication false
UseDeadLetterQueue false
UseEncryption false
UseJournalQueue false
UseTracing false

You can change the value for any of these properties through a separate call to the property.

Example [Visual Basic]

The following example creates an message with the body "New Message." The example then sends the message to a queue. It assumes there is a queue on the computer "myComputer" with the name "myQueue".

Import the System.Messaging namespace for this example.

[Visual Basic]

Private Sub CreateMessage()
    'Declare a message and message queue
    Dim msg As Message
    Dim mq As MessageQueue
    
    'Instantiate a message with the given body.
    msg = New Message("New Message.")
   
    'Instantiate a new MessageQueue object
    mq = New MessageQueue("myComputer\myQueue")

    'Send the message to the queue.
    mq.Send(msg)
End Sub

See Also

Message Class | Message Members | System.Messaging Namespace | Message Constructor Overload List | AcknowledgeType | CryptoProviderType | EncryptionAlgorithm | HashAlgorithm | MessagePriority | SoapMessageFormatter | InfiniteTimeout | Guid | Stream | Send | Peek | Receive