C# 类型为';的未处理异常;System.OutOfMemoryException';发生在System.Xml.dll中
我有以下代码:C# 类型为';的未处理异常;System.OutOfMemoryException';发生在System.Xml.dll中,c#,.net,xml,out-of-memory,xmldocument,C#,.net,Xml,Out Of Memory,Xmldocument,我有以下代码: XmlTextReader DBLPReader = new XmlTextReader("dblp.xml"); // Load the source of the XML file into an XmlDocument XmlDocument DBLPDoc = new XmlDocument(); // Load the source XML file into the first document DBLPDoc.Load(DBLPReader); // Clos
XmlTextReader DBLPReader = new XmlTextReader("dblp.xml");
// Load the source of the XML file into an XmlDocument
XmlDocument DBLPDoc = new XmlDocument();
// Load the source XML file into the first document
DBLPDoc.Load(DBLPReader);
// Close the reader
DBLPReader.Close();`
其中dblp
大约有800MB
我收到一个错误,上面写着“System.Xml.dll中发生了类型为'System.OutOfMemoryException'的未处理异常”
这种情况下的解决方案是什么?根据您试图实现的目标,您的解决方案可能是:
- 使用SAX解析器
- 使用64位机器
- 不要试图加载这么大的文件
- 使文件更小(例如,消除空白或注释,缩短标记名)
- 捕获异常并正确处理它