XmlMessageFormatter.Write(Message, Object) 方法

定義

將物件序列化到訊息主體中。Serializes an object into the body of the message.

public:
 virtual void Write(System::Messaging::Message ^ message, System::Object ^ obj);
public void Write (System.Messaging.Message message, object obj);
abstract member Write : System.Messaging.Message * obj -> unit
override this.Write : System.Messaging.Message * obj -> unit
Public Sub Write (message As Message, obj As Object)

參數

message
Message

Message,其 Body 屬性會包含序列化物件。The Message whose Body property will contain the serialized object.

obj
Object

要序列化到訊息主體中的 ObjectThe Object to be serialized into the message body.

實作

例外狀況

message 參數為 nullThe message parameter is null.

-或--or- obj 參數為 nullThe obj parameter is null.

備註

不需要指定目標型別來寫入佇列,因為它們在讀取時必須是。The target types need not be specified to write to the queue as they must be when reading. TargetTypeNames TargetTypes 只有在還原序列化訊息時,格式器才會使用或屬性。The TargetTypeNames or TargetTypes property is used by the formatter only when deserializing a message.

XmlMessageFormatter會使用 XmlSerializer 類別,以定義可序列化的內容。The XmlMessageFormatter makes use of the XmlSerializer class, which defines what can be serialized. 只有公用欄位和公用屬性可以序列化。Only public fields and public properties can be serialized. 結構、具有陣列的結構,以及結構的陣列都是可序列化的,前提是它們不會使用編碼的樣式搭配 SOAP 通訊協定。Structures, structures with arrays, and arrays of structures are all serializable, as long as they do not use the encoded style with the SOAP protocol.

適用於

另請參閱