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

要序列化到消息体中的对象。The object to be serialized into the message body.

实现

例外

message 参数为 nullThe message parameter is null.

注解

重要

使用不受信任的数据调用此方法存在安全风险。Calling this method with untrusted data is a security risk. 仅使用受信任的数据调用此方法。Call this method only with trusted data. 有关详细信息,请参阅数据验证For more information, see Data Validation.

在读取时,不需要指定 top 对象格式和类型格式来写入队列。The top object format and type format need not be specified to write to the queue as they must be when reading. TopObjectFormat TypeFormat 仅当反序列化消息时,格式化程序才使用和属性。The TopObjectFormat and TypeFormat properties are used by the formatter only when deserializing a message.

BinaryMessageFormatter可以序列化大多数对象,但结果并不松耦合。The BinaryMessageFormatter can serialize most objects, but the result is not loosely coupled. 不过,它是压缩的,因此格式化程序对于大型对象是高效的。However, it is compact, so the formatter is efficient for large objects.

适用于

另请参阅