Message.BodyType Property

Definition

Gets or sets the type of data that the message body contains.

C#
[System.Messaging.MessagingDescription("MsgBodyType")]
public int BodyType { get; set; }

Property Value

The message body's true type, such as a string, a date, a currency, or a number.

Attributes

Exceptions

The message queue is filtered to ignore the Body property.

Examples

The following code example displays the value of a message's BodyType property.

Remarks

Message Queuing recognizes the body contents as an object or as a serialized stream. The BodyType property indicates the type of the object within the Body property of the message.

The XmlMessageFormatter performs binding between native types and the object in a message body. If you use the XmlMessageFormatter, the formatter sets the BodyType property for you.

Other formatters can provide binding functionality also, as shown in the following C# code.

message.Formatter = new ActiveXMessageFormatter();  
object myObject message.Body;  
if (myObject is string) {  
}  
if (myObject is int) {  
}  
if (myObject is float) {  
}  

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also