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.


訊息的本文可以包含任何類型的資訊,例如字串、日期、貨幣、數位、位元組陣列或任何 managed 物件。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 針對此訊息的本文將屬性設為,則訊息會在傳送時加密,而不是在您設定屬性時 Body 加密。If 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.