While reading and adding xml file to list of object.
I get 'System.OutOfMemoryException'.
I could have more than 6000000 xml files which I am not sure
my code:
foreach (var xml in xmlFiles)
{
{
try
{
XmlRootAttribute xRoot = new XmlRootAttribute
{
ElementName = "CASE",
IsNullable = true
};
{
XmlRootAttribute xRoot = new XmlRootAttribute
{
ElementName = "CASE",
IsNullable = true
};
XmlSerializer xs = new XmlSerializer(typeof(MyTable), xRoot);
MyTable cs = new MyTable();
MyTable cs = new MyTable();
using (var sr = new StreamReader(xml))
{
cs = (MyTable)xs.Deserialize(sr);
// cases.Add(cs);
LoadtToLocalDB(cs);
}
{
cs = (MyTable)xs.Deserialize(sr);
// cases.Add(cs);
LoadtToLocalDB(cs);
}
}
catch (Exception ex)
{
catch (Exception ex)
{
using (var writer = new StreamWriter(errorLog, false))
{
writer.WriteLine(xml);
writer.WriteLine(ex.Message);
writer.WriteLine("----------------------------------------------------------------------------------");
}
}
}
{
writer.WriteLine(xml);
writer.WriteLine(ex.Message);
writer.WriteLine("----------------------------------------------------------------------------------");
}
}
}
Jignesh KumarPosted Apr 27, 2019, 2:01 AM
Sam VPosted Apr 30, 2019, 2:35 PM
Amit KumarPosted Apr 27, 2019, 1:49 AM
Amit GuptaPosted Apr 26, 2019, 8:31 AM