Export (0) Print
Expand All

Message.BodyType Property

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

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

[MessagingDescriptionAttribute("MsgBodyType")]
public int BodyType { get; set; }

Property Value

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

ExceptionCondition
InvalidOperationException

The message queue is filtered to ignore the Body property.

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) {
}

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

// Display the value of the message's BodyType property.
Console.WriteLine("Message.BodyType: {0}",
    orderMessage.BodyType.ToString());

.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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft