C# Trying to serialize an ArrayList into an XML file




struct ClientInfo
{
public string strName; //Name by which the user logged into the chat room
public string strPW;
}

ArrayList clientList = new ArrayList();

public static void Serialize(ArrayList input)
{
XmlSerializer serializer = new XmlSerializer(input.GetType());
TextWriter sw = new StreamWriter("users.txt");
serializer.Serialize(sw, input);
sw.Close();
}


So I am trying to store Name/Password combinations in an ArrayList and I am trying to save this ArrayList into a file, and load it every time the program is started. However, the program stops at the serializer.Serialize(sw, input); line with the following:



An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll



What am I doing wrong ?


No comments:

Post a Comment