Message.BodyStream 属性


获取或设置消息正文中的信息。Gets or sets the information in the body of the message.

 property System::IO::Stream ^ BodyStream { System::IO::Stream ^ get(); void set(System::IO::Stream ^ value); };
public System.IO.Stream BodyStream { get; set; }
member this.BodyStream : System.IO.Stream with get, set
Public Property BodyStream As Stream



Stream,包含消息的 Body 中包括的已序列化信息。A Stream that contains the serialized information included in the Body of the message.



消息队列经过筛选后忽略了 Body 属性。The message queue is filtered to ignore the Body property.


消息的正文可以包含任何类型的信息(例如,字符串、日期、货币、数字、字节数组或任何托管对象)。The body of a message can consist of any type of information - for example, a string, a date, a currency, a number, an array of bytes, or any managed object. 此信息将序列化为 Stream 要传递到队列的。This information is serialized into a Stream to be passed to the queue.

Body发送对象之前,请指定属性或 BodyStream 属性 MessageSpecify either the Body property or the BodyStream property before sending the Message object. 如果设置了 Body 属性,则会将内容序列化到 BodyStream 属性中。If you set the Body property, the contents are serialized into the BodyStream property. 不过,您可以选择 BodyStream 直接编写属性。However, you can choose to write the BodyStream property directly. 这很有用,例如,当你想要打开到文件的连接并将其内容流式传输为消息正文时,这很有用。This is useful, for example, when you want to open a connection to a file and stream its contents as the body of your message.

除非将消息内容直接写入 BodyStream 属性,否则在 Formatter 发送消息之前,请设置属性。Unless you write the contents of the message directly to the BodyStream property, set the Formatter property before you send the message. Send 实例上调用方法时 MessageQueue ,使用属性中包含的格式化程序对正文进行序列化 FormatterWhen the Send method is called on the MessageQueue instance, the body is serialized using the formatter contained in the Formatter property. 如果在未指定属性值的情况下发送消息 Formatter ,则格式化程序默认为 XmlMessageFormatterIf you send the message without specifying a value for the Formatter property, the formatter defaults to XmlMessageFormatter.

如果将 UseEncryption 此消息正文的属性设置为,则在 true 发送消息时将加密该消息,而不是在设置属性时加密 BodyIf you set the UseEncryption property to true for the body of this message, the message will be encrypted when it is sent, not when you set the Body property. 因此,永远不会 BodyStream 加密该属性。Therefore, the BodyStream property is never encrypted.