Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. XML Serializing an Object that Inherits a List of itself

XML Serializing an Object that Inherits a List of itself

Scheduled Pinned Locked Moved C#
helpxmljsonquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Patricker
    wrote on last edited by
    #1

    I have an object, called Tag, which inherits List<Tag>.   This works great code wise, I can add objects of type tag to my tag without issue.   But when I try to serialize the object to XML it crashes with a "An unhandled exception of type 'System.StackOverflowException' occurred in System.Xml.dll" error when I try to initialize a new instances the XmlSerializer class, and pass in the type of Tag. If I remove the Inherts List<Tag> and just create a new property of type List<Tag> instead, then this serializes great, but does not give me quite the appearance I want.   Is there someway to make this work without custom serialization, or maybe only minor custom serialization? Thanks,    Peter

    W 1 Reply Last reply
    0
    • P Patricker

      I have an object, called Tag, which inherits List<Tag>.   This works great code wise, I can add objects of type tag to my tag without issue.   But when I try to serialize the object to XML it crashes with a "An unhandled exception of type 'System.StackOverflowException' occurred in System.Xml.dll" error when I try to initialize a new instances the XmlSerializer class, and pass in the type of Tag. If I remove the Inherts List<Tag> and just create a new property of type List<Tag> instead, then this serializes great, but does not give me quite the appearance I want.   Is there someway to make this work without custom serialization, or maybe only minor custom serialization? Thanks,    Peter

      W Offline
      W Offline
      Webnoi
      wrote on last edited by
      #2

      Im having the same issue. Have you found the solution?

      P 1 Reply Last reply
      0
      • W Webnoi

        Im having the same issue. Have you found the solution?

        P Offline
        P Offline
        Patricker
        wrote on last edited by
        #3

        Nope, never did find a work around, ended up doing it a different way, can't remember exactly how right now.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups