내 응용 프로그램에서 XML 문자열에 큰 개체를 serialize해야합니다. 그런 다음 System.OutOfMemory 예외를 throw합니다. 어떻게 예외없이 그리고 압축없이 객체를 직렬화 할 수 있습니까? 여기에 빠른 구글 searche를 통해 accesed 수 있습니다 유래에 여기 좋은 answeers 많은이개체를 XML로 직렬화하고 메모리에서 압축하는 방법
public static string GenerateXMLData<T>(T data)
{
byte[] bytes;
using (var memoryStream = new MemoryStream())
{
using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Compress))
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(gZipStream, data);
}
bytes = memoryStream.ToArray();
}
return Encoding.UTF8.GetString(bytes);
}
[BinaryFormatter 대 수동 직렬화] (http://www.codeproject.com/Articles/311944/BinaryFormatter- 또는 --Manual-serializing)가 유용 할 수 있습니다. – Yuriy