Xmlmessageformatter in MSMQ specifies serializable attributes

Source: Internet
Author: User
Tags msmq
Preface

This is a mck note about using the MS messagequeue Microsoft Message Queue component now moved to the blog

Throw when MSMQ is used to send messages:

Icontlliton <t> is an error in interface serialization failure.

The message to be sent is a complex entity:

Public class modelone
{

Public string name {Get; set ;}

Public modeltwo model {Get; set ;}

}

Public class modeltwo

{

Public string name {Get; set ;}

Public ilist <modlethree> List {Get; set ;}

}

 

In modeltwo, APIs in modeltwo cannot be serialized. However, list does not need to be serialized.

To specify the attributes to be serialized, you can use
[Xmlignore] label. This label indicates attribute fields that do not need to be serialized.

 

For more information about XML
Attriabute during serialization:

The system. xml. serialization namespace has a series of feature classes used to control the control of complex type serialization. For example
Xmlelementattribute, xmlattributeattribute, xmlarrayattribute,
Xmlarrayitemattribute and xmlrootattribute

 

[Xmlroot ("cat")]

Public class cat

{

// Define the serialization of the color attribute as the attributes of the cat Node

[Xmlattribute ("color")]
Public
String color {Get; set ;}


// The speed attribute is not serialized.

[Xmlignore]
Public int Speed {
Get; set ;}


// Serialize the saying attribute to an XML sub-element.

[Xmlelement ("saying")]
Public
String saying {Get; set ;}
}
}

You can use xmlelement to specify the property to be serialized as a sub-node (the property will be serialized as a sub-node by default), or use the xmlattribute feature to specify the property to be serialized as an XML node. You can also use the xmlignore feature to modify the serialization requirements.ProgramModify attributes without serialization

Reference

Http://www.cnblogs.com/luomingui/archive/2010/03/08/1680933.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.