Results 1 to 3 of 3

Thread: Xml Serialization question

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Xml Serialization question

    I have a static class.
    this static class has a reference to 2 other static classes.

    I want to be able to serialize/deserialize this class, so it serializes/deserializes ClassA and ClassB properties/values.

    so...

    ClassA

    Code:
    private static SomeClassA theStaticClassA;
    private static SomeClassB theStaticClassB;
    I would like the properties of these 2 classes to be serialized and deserialized.

    how can I do this? (.NET 2.0)


    currently I am doing this

    Code:
    XmlSerializer theXmlSerializer = new XmlSerializer(TheMouseManager.GetType());
    
                StreamWriter theTextWriter = new StreamWriter(theApplicationConfigName);
                theXmlSerializer.Serialize(theTextWriter, TheMouseManager);
                theTextWriter.Close();
    however nothing gets serialized even though there are properties and values set to those properties in this class.
    Last edited by Techno; Jul 6th, 2006 at 09:20 PM.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Xml Serialization question

    If you have a static class then you cannot serialise it because serialisation is an operation that you perfrom on objects. An object is an instance of a type, and given that you cannot create an instance of a static class you cannot possibly serialise one.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Xml Serialization question

    thanks...
    guess ill manually write the values to xml

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width