Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

NetCF version 2.0 supports XMLSerialzier. Are there performance tips to make the XMLSerializer faster?

0
Posted

NetCF version 2.0 supports XMLSerialzier. Are there performance tips to make the XMLSerializer faster?

0

Serialization metadata for a given type is built when a corresponding XmlSerializer is created: new XmlSerializer(typeof(MyType)); (Metadata is built for type MyType) Building this metadata is expensive so the metadata is cached by the XmlSerializer. It is recommended that applications only create one XmlSerializer instance per type to reduce the amount of time spent searching for metadata. Use the “Singleton pattern”. If serializing several types use FromTypes(): // Create the list of serializer Type[] types = new Type[]{typeof(MyType1), typeof(MyType2)}; XmlSerializer[] serializers = XmlSerializer.FromTypes(types); // Serialize an instance of MyType1 MyType1 mt1 = new MyType1(); serializers[0].

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123