Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7636515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:42:05+00:00 2026-05-31T07:42:05+00:00

I use a XmlSerializer to serialize/deserialize some objects. The problem is the performance. When

  • 0

I use a XmlSerializer to serialize/deserialize some objects. The problem is the performance. When profiling, using the XmlSerializer make our application 2 seconds longer to start. We cache our XmlSerializer and reuse them. We cannot use sgen.exe because we are creating the XmlSerializer with XmlAttributeOverrides.

I try to use serialization alternative like Json.Net and, at first, it’s work great. The problem is that we need to be backward compatible so all the xml already generated need to be parsed correctly. Also, the object serialization output must be Xml.

To summarize:

  1. I receive Xml data serialized by a XmlSerializer.
  2. I need to deserialize the Xml data and convert it into an object.
  3. I need to serialize object into Xml (ideally an Xml format like the one a XmlSerializer would have done)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:42:06+00:00Added an answer on May 31, 2026 at 7:42 am

    Ultimately, it depends on the complexity of your model. XmlSerializer needs to do a lot of thinking, and the fact that it is taking so long leads me to suspect that your model is pretty complex. For a simple model, it might be possible to manually implement the deserialization using LINQ-to-XML (pretty easy), or maybe even XmlReader (if you are feeling very brave – it isn’t easy to get 100% correct).

    However, if the model is complex, this is a problem and frankly would be very risky in terms of introducing subtle bugs.

    Another option is DataContractSerializer which handles xml, but not as well as XmlSerializer, and certainly not with as much control over the layout. I strongly suspect that DataContractSerializer would not help you.

    There is no direct replacement for XmlSerializer that I am aware of, and if sgen.exe isn’t an option I believe you basically have options:

    • live with it
    • rewrite XmlSerializer yourself, somehow doing better than them
    • use something like LINQ-to-XML and accept the effort involved

    Long term, I’d say “switch formats”, and use xml for legacy import only. I happen to know of some very fast binary protocols that would be pretty easy to substitute in ;p

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm using XmlSerializer to serialize and deserialize an object. The xml is generated
I use C# code more-or-less like this to serialize an object to XML: XmlSerializer
I'm trying to serialize a class derived from List<> using DataContract. The problem is
Basically, the initial problem is I need to make a boolean value serialize as
I'm using XmlSerializer to serialize an object that contains a generic list List <ChildBase>
I need to serialize/de-serialize some objects into/from string and transfer them as just opaque
In C#, how do I use an XmlSerializer to deserialize an object that might
I'm writing a C#.NET program which uses XmlSerializer to serialize and deserialize the project
I have some types that I want to serialize/deserialize and generate a UI based
I know how to serialize in F# using mutable objects, but is there a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.