TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Istudent Rana
1.4k
340
83.4k
Exception of type 'System.OutOfMemoryException' was thrown
Apr 26 2019 7:48 AM
I am trying to read xml files and load the data to data base.
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
};
XmlSerializer xs = new XmlSerializer(typeof(MyTable), xRoot);
MyTable cs = new MyTable();
using (var sr = new StreamReader(xml))
{
cs = (MyTable)xs.Deserialize(sr);
// cases.Add(cs);
LoadtToLocalDB(cs);
}
}
catch (Exception ex)
{
using (var writer = new StreamWriter(errorLog, false))
{
writer.WriteLine(xml);
writer.WriteLine(ex.Message);
writer.WriteLine("----------------------------------------------------------------------------------");
}
}
}
Reply
Answers (
4
)
when we should use the "private protected" in C#?
How to get an Not Empty Instance back ?