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

Thread: XML Problem, not all properties get serialized

  1. #1
    Join Date
    Feb 2002
    Location
    New Jersey
    Posts
    160

    XML Problem, not all properties get serialized

    My project includes a class which is serialized to an XML string but for some reason not all of the properties get serialized and I cannot figure out why, pleas help
    In the code below callID and global CallID get serilized but "cause" does not

    Code:
    [System.Runtime.Serialization.DataMemberAttribute()]
            public string callID { get; set; }
    
            [System.Runtime.Serialization.DataMemberAttribute()]
            public string globalCallID { get; set; }
    
            [System.Runtime.Serialization.DataMemberAttribute()]
            public string cause { get; set; }
    this is my serialization code

    Code:
    public string Serializew(object popo,Encoding _Encoding)
            {
                System.IO.StreamReader streamReader = null;
                System.IO.MemoryStream memoryStream = null;
                try
                {
                    memoryStream = new System.IO.MemoryStream();
                    XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, _Encoding);
                    Serializer.Serialize(xmlTextWriter, popo);
                    memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
                    streamReader = new System.IO.StreamReader(memoryStream);
                    return streamReader.ReadToEnd();
                }
                finally
                {
                    if ((streamReader != null))
                    {
                        streamReader.Dispose();
                    }
                    if ((memoryStream != null))
                    {
                        memoryStream.Dispose();
                    }
                }
            }
            private static System.Xml.Serialization.XmlSerializer serializer;
            private static System.Xml.Serialization.XmlSerializer Serializer
            {
                get
                {
                    if ((serializer == null))
                    {
                        serializer = new System.Xml.Serialization.XmlSerializer(typeof(ImmMessage));
                    }
                    return serializer;
                }
    
            }

  2. #2
    Join Date
    Feb 2002
    Location
    New Jersey
    Posts
    160

    Re: XML Problem, not all properties get serialized

    Found the problem, it was in my code.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)