У меня есть объект XElement
, который содержит около 120 МБ данных. XML состоит из примерно 6000 элементов по 20 кбайт каждый.XElement.ToString() вызывает System.OutOfMemoryException
Я пытаюсь позвонить XElement.ToString()
, поскольку мне нужно вернуть OuterXml в веб-сервис.
Я получаю System.OutOfMemoryException
.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
at System.Text.StringBuilder.Append(Char[] value, Int32 startIndex, Int32 charCount)
at System.IO.StringWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.Xml.XmlEncodedRawTextWriter.FlushBuffer()
at System.Xml.XmlEncodedRawTextWriter.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)
at System.Xml.XmlEncodedRawTextWriter.WriteString(String text)
at System.Xml.XmlEncodedRawTextWriterIndent.WriteString(String text)
at System.Xml.XmlWellFormedWriter.WriteString(String text)
at System.Xml.XmlWriter.WriteAttributeString(String prefix, String localName, String ns, String value)
at System.Xml.Linq.ElementWriter.WriteStartElement(XElement e)
at System.Xml.Linq.ElementWriter.WriteElement(XElement e)
at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
at System.Xml.Linq.XNode.GetXmlString(SaveOptions o)
at System.Xml.Linq.XNode.ToString()
У меня есть одни и те же данные в качестве XmlDocument
и может назвать XmlDocument.OuterXml
без проблем. Я также могу позвонить XElement.Save()
, чтобы сохранить XML в файл без проблем.
Может ли кто-нибудь предложить альтернативу XElement.ToString(), которая будет менее интенсивной в памяти? Или, альтернативно, некоторые параметры, которые я могу установить, позволят увеличить пространство памяти?
Вам необходимо вернуть 120 мб данных через веб-службу ... – Phill 2010-11-25 09:36:02
вот что я думал ... – 2010-11-25 09:39:12