i'm using this class
public class Branch
{
public string Name { get; set; }
public User Manager { get; set; }
public User Secretary { get; set; }
public Dictionary<string, User> Broker;
public Dictionary<string, Apartment> Apartments;
public Branch()
{}
public Branch(Branch other)
{
Name = other.Name;
Manager = other.Manager;
Secretary = other.Secretary;
Broker = other.Broker;
Apartments = other.Apartments;
}
}
trying to run this line : Dict2XML.Save_Branch2XML(Branchs);
through this method:
static public void Save_Branch2XML(Dictionary<string, Branch> D)
{
//List<KeyValuePair<string, User>> DictionList = D.ToList();
List<Branch> DictionList = D.Select(p => new Branch(p.Value)).ToList<Branch>();
XmlSerializer Serializer = new XmlSerializer(DictionList.GetType());
TextWriter writer = new StreamWriter(@"C:\Users\tzach_000\Documents\Visual Studio 2013\Projects\RealEstate\RealEstate\DB\XMLBranch.xml");
Serializer.Serialize(writer, DictionList);
writer.Close();
}
and the program collapse when it gets to the XmlSerializer
line in save_branch2xml
method.