473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem deserializing ArrayList.

I have a wierd one that I hope somebody can help with.

I'm trying to serialize an ArrayList of items. I am successfully serializing
other ArrayLists of strings, but for some reason this code will serialize
*out* the CommentLines property, but the XmlSerializer seems to ignore them
when serializing them back in. Here is my code:

[Serializable]
public class PatchArchiveStats
{
ArrayList m_arrDiffItems = new ArrayList();

[XmlArrayItem( "DiffItem", typeof(DiffItem) )]
public ArrayList DiffItems {
get {
return m_arrDiffItems;
}
set {
m_arrDiffItems = value;
}
}
}

[Serializable]
public class DiffItem
{
string m_strComment; // A multi-line comment.

[XmlArray("CommentLines")]
[XmlArrayItem( "CommentLine", typeof(string) )]
public ArrayList CommentLines {
get {

ArrayList lines = new ArrayList();
if ( m_strComment != null ) {

string strLine = null;
StringReader reader = new StringReader( m_strComment );
while ( (strLine = reader.ReadLine()) != null ) {

lines.Add( strLine );
}
}

return lines;
}
set {
m_strComment = null;
foreach ( string strLine in value ) {
if ( strLine == null ) {
continue;
}
if ( m_strComment == null ) {
m_strComment = strLine;
}
else {
m_strComment += "\n" + strLine;
}
}
}
}
}

Any help would be very much appreciated!
Nov 12 '05 #1
1 2109
"Chris Mumford" <ch**********@sbcglobal.net> wrote in message
news:UU*****************@newssvr23.news.prodigy.co m...
I have a wierd one that I hope somebody can help with.

I'm trying to serialize an ArrayList of items. I am successfully serializing other ArrayLists of strings, but for some reason this code will serialize
*out* the CommentLines property, but the XmlSerializer seems to ignore them when serializing them back in. Here is my code:


<snip>

Take a look at this tutorial. It might help point you in the right
direction...

http://www.devhood.com/tutorials/tut...utorial_id=542

Hope it helps..

Ted
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin Armstrong | last post by:
I'm having difficulties deserializing some objects. Consider the following example of what I'm trying to do: ---------------------------------------------------------- class Person { string...
1
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which...
2
by: Richard | last post by:
I've used XMLSerializer before to store user settings with great success, but this is the first time I've tried to serialize an Array. It serializes fine, but when I try to deserialize it, I get...
4
by: Wayne Wengert | last post by:
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in...
1
by: Paul Fi | last post by:
I have this client code: string server = "localhost"; int port = 8085; IPHostEntry hostent = Dns.Resolve(server); IPAddress hostadd = hostent.AddressList; IPEndPoint EPhost = new...
10
by: gregbacchus | last post by:
Can someone please help me and tell my why the following code is not working, and hopefully how to get it working? What I am trying to do is make a serialization surrogate that stores, amongst...
2
by: Tiraman :-\) | last post by:
Hi Everyone, i have the following problem in my client-server Application My server take array and serialize it into the memorystream Dim ns As NetworkStream = client.GetStream() Dim writer...
1
by: Mike9900 | last post by:
Hello, We have a serialized XML from version 1.1 of .NET Framework and want to deserialize it in .NET Framework 2.0, but it failes to do so with the following error: Parse Error, no assembly...
9
by: norvinl | last post by:
Hi, I'm serializing a class and using shared memory / deserialization to send it to other processes. I can serialize with one app and deserialize with another instance of the same app. But...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.