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.

适用于

另请参阅