Export (0) Print
Expand All

Message Constructor (Object, IMessageFormatter)

Initializes a new instance of the Message class using the specified formatter to serialize the specified object into the body of the message.

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

new : 
        body:Object * 
        formatter:IMessageFormatter -> Message

Parameters

body
Type: System.Object

The object to be serialized into the body of the message.

formatter
Type: System.Messaging.IMessageFormatter

A IMessageFormatter that specifies the formatter with which to serialize the message body.

Use this overload to create a new instance of the Message class that contains the Body specified by the body parameter and that uses any valid formatter to serialize the body. The body parameter is any object that can be serialized, such as a text string, a structure object, a class instance, or an embedded object. If you change the Body or Formatter property at any time before calling Send, the message will be serialized according to the new property value.

The XmlMessageFormatter is loosely coupled, so it is not necessary to have the same object type on the sender and receiver when using this format. The ActiveXMessageFormatter and BinaryMessageFormatter serialize the data into binary representation. The ActiveXMessageFormatter is used when sending or receiving COM components.

The following table shows initial property values for an instance of Message.

Property

Initial value

AcknowledgeType

AcknowledgeType.None

AdministrationQueue

a null reference (Nothing in Visual Basic)

AppSpecific

0

AttachSenderId

true

AuthenticationProviderName

Microsoft Base Cryptographic Provider version 1.0

AuthenticationProviderType

CryptoProviderType.RSA_FULL

Body

The body parameter.

BodyStream

Stream.null

BodyType

0

ConnectorType

Guid.Empty

CorrelationId

An 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

The formatter parameter.

HashAlgorithm

HashAlgorithm.MD5

Label

An empty string ("")

Priority

MessagePriority.Normal

Recoverable

false

ResponseQueue

a null reference (Nothing in Visual Basic)

SenderCertificate

A zero-length array of bytes

TimeToBeReceived

Message.InfiniteTimeout

TimeToReachQueue

Message.InfiniteTimeout

TransactionStatusQueue

a null reference (Nothing in Visual Basic)

UseAuthentication

false

UseDeadLetterQueue

false

UseEncryption

false

UseJournalQueue

false

UseTracing

false

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

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft