开发者

MSMQ Complex Object Serialization/Deserialization

I am attempting to send a message to MSMQ utilizing the XmlFormatter 开发者_JAVA百科for an object that contains a property of type object. If the object property is left null, the serialization/deserialization works flawlessly. However, if I assign an object I receive an exception when invoking .send. There was an error generating the XML document is the only information that I receive. Both classes are marked serializable. Is there something else that I need to do?

Thanks.


I suspect that your objects are not properly serialized into XML.

how does it work for example if you simply assign a string value to the object property?

You can use a small console app or the debugger to test how your classes are serialized and deserialized to/from xml and check the behavior of the XmlFormatter.


Even though your complex class declares a property as type object, when something is assigned to it, serialization sees the property as an object of the type assigned.

For example, if you assign your object property a value of new CustomClass(), serialization will expect an object(), but find a CustomClass(), so serialization will fail. (Type CustomClasss was not expected)

If you assign your object property a value of new object(), I suspect the serialization will then work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜