CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    May 2003
    Posts
    18

    Question Why does deserialization fail?

    XML:
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <TTTTModel>
        <TTTTClass>
            <TTTTType>Deployment</TTTTType>
            <TTTTDate>2009-09-30T00:00:00-07:00</TTTTDate>
        </TTTTClass>
        <TTTTClass>
            <TTTTType>Deployment</TTTTType>
            <TTTTDate>2009-09-20T00:00:00-07:00</TTTTDate>
        </TTTTClass>
        <TTTTClass>
            <TTTTType>Copy</TTTTType>
            <TTTTDate>2009-02-23T00:00:00-07:00</TTTTDate>
        </TTTTClass>
    </TTTTModel>

    The code:

    Code:
    [Serializable]
        public class ActionClass
        {
            [XmlElement(Form=XmlSchemaForm.Unqualified)]
            public string ActionType { get; set; }
            [XmlElement(Form = XmlSchemaForm.Unqualified)]
            public DateTime ActionDate { get; set; }
        }
    
    
    
    
        public class ActionModel : List<ActionClass>
        {
            public ActionModel()
            {
                XmlSerializer xs = new XmlSerializer(typeof(ActionModel), "");
    
                using (Stream ms = new FileStream("Demo.xml", FileMode.Open, FileAccess.Read))
                {
                    object inp = xs.Deserialize(ms);
                    this.AddRange((ActionModel)inp);
                }
            }
        }

    Why I get exception on object inp = xs.Deserialize(ms)?


    <ActionModel xmlns=''> was not expected.

    How to fix it?
    Last edited by Arjay; November 27th, 2009 at 07:48 PM.

Tags for this Thread

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

Featured