Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs	(revision 12454)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs	(revision 12455)
@@ -311,4 +311,60 @@
     }
 
+    private static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies
+   , CompressionLevel compression) {
+      Serializer serializer = new Serializer(obj, config);
+      Serialize(stream, includeAssemblies, compression, serializer);
+    }
+
+    private static void Serialize(Stream stream, bool includeAssemblies, CompressionLevel compression, Serializer serializer) {
+      try {
+        DateTime start = DateTime.Now;
+        serializer.InterleaveTypeInformation = false;
+        XmlGenerator generator = new XmlGenerator();
+        using (ZipArchive zipArchive = new ZipArchive(stream, ZipArchiveMode.Create)) {
+          ZipArchiveEntry entry = zipArchive.CreateEntry("data.xml", compression);
+          using (StreamWriter writer = new StreamWriter(entry.Open())) {
+            foreach (ISerializationToken token in serializer) {
+              string line = generator.Format(token);
+              writer.Write(line);
+            }
+          }
+          entry = zipArchive.CreateEntry("typecache.xml", compression);
+          using (StreamWriter writer = new StreamWriter(entry.Open())) {
+            foreach (string line in generator.Format(serializer.TypeCache)) {
+              writer.Write(line);
+            }
+          }
+          if (includeAssemblies) {
+            foreach (string name in serializer.RequiredFiles) {
+              Uri uri = new Uri(name);
+              if (!uri.IsFile) {
+                Logger.Warn("cannot read non-local files");
+                continue;
+              }
+              entry = zipArchive.CreateEntry(Path.GetFileName(uri.PathAndQuery), compression);
+              using (BinaryWriter bw = new BinaryWriter(entry.Open())) {
+                using (FileStream reader = File.OpenRead(uri.PathAndQuery)) {
+                  byte[] buffer = new byte[1024 * 1024];
+                  while (true) {
+                    int bytesRead = reader.Read(buffer, 0, 1024 * 1024);
+                    if (bytesRead == 0)
+                      break;
+                    bw.Write(buffer, 0, bytesRead);
+                  }
+                }
+              }
+            }
+          }
+        }
+        Logger.Info(String.Format("serialization took {0} seconds with compression level {1}",
+          (DateTime.Now - start).TotalSeconds, compression));
+      }
+      catch (Exception) {
+        Logger.Warn("Exception caught, no data has been serialized.");
+        throw;
+      }
+    }
+
     /// <summary>
     /// Serializes the specified object into a file.
@@ -322,48 +378,9 @@
       try {
         string tempfile = Path.GetTempFileName();
-        DateTime start = DateTime.Now;
+
         using (FileStream stream = File.Create(tempfile)) {
-          Serializer serializer = new Serializer(obj, config);
-          serializer.InterleaveTypeInformation = false;
-          XmlGenerator generator = new XmlGenerator();
-          using (ZipArchive zipArchive = new ZipArchive(stream, ZipArchiveMode.Create)) {
-            ZipArchiveEntry entry = zipArchive.CreateEntry("data.xml", compression);
-            using (StreamWriter writer = new StreamWriter(entry.Open())) {
-              foreach (ISerializationToken token in serializer) {
-                string line = generator.Format(token);
-                writer.Write(line);
-              }
-            }
-            entry = zipArchive.CreateEntry("typecache.xml", compression);
-            using (StreamWriter writer = new StreamWriter(entry.Open())) {
-              foreach (string line in generator.Format(serializer.TypeCache)) {
-                writer.Write(line);
-              }
-            }
-            if (includeAssemblies) {
-              foreach (string name in serializer.RequiredFiles) {
-                Uri uri = new Uri(name);
-                if (!uri.IsFile) {
-                  Logger.Warn("cannot read non-local files");
-                  continue;
-                }
-                entry = zipArchive.CreateEntry(Path.GetFileName(uri.PathAndQuery), compression);
-                using (BinaryWriter bw = new BinaryWriter(entry.Open())) {
-                  using (FileStream reader = File.OpenRead(uri.PathAndQuery)) {
-                    byte[] buffer = new byte[1024 * 1024];
-                    while (true) {
-                      int bytesRead = reader.Read(buffer, 0, 1024 * 1024);
-                      if (bytesRead == 0)
-                        break;
-                      bw.Write(buffer, 0, bytesRead);
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-        Logger.Info(String.Format("serialization took {0} seconds with compression level {1}",
-          (DateTime.Now - start).TotalSeconds, compression));
+          Serialize(obj, stream, config, includeAssemblies, compression);
+        }
+
         File.Copy(tempfile, filename, true);
         File.Delete(tempfile);
@@ -381,6 +398,7 @@
     /// <param name="obj">The object.</param>
     /// <param name="stream">The stream.</param>
-    public static void Serialize(object obj, Stream stream) {
-      Serialize(obj, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()));
+    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
+    public static void Serialize(object obj, Stream stream, bool useZip = false) {
+      Serialize(obj, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), useZip);
     }
 
@@ -392,6 +410,7 @@
     /// <param name="stream">The stream.</param>
     /// <param name="config">The configuration.</param>
-    public static void Serialize(object obj, Stream stream, Configuration config) {
-      Serialize(obj, stream, config, false);
+    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
+    public static void Serialize(object obj, Stream stream, Configuration config, bool useZip = false) {
+      Serialize(obj, stream, config, false, useZip);
     }
 
@@ -403,8 +422,13 @@
     /// <param name="config">The configuration.</param>
     /// <param name="includeAssemblies">if set to <c>true</c> include need assemblies.</param>
-    public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies) {
+    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
+    public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, bool useZip = false) {
       try {
         Serializer serializer = new Serializer(obj, config);
-        Serialize(stream, serializer);
+        if (useZip) {
+          Serialize(obj, stream, config, includeAssemblies, CompressionLevel.Optimal);
+        } else {
+          Serialize(stream, serializer);
+        }
       }
       catch (PersistenceException) {
@@ -424,8 +448,13 @@
     /// <param name="includeAssemblies">if set to <c>true</c> include need assemblies.</param>
     /// <param name="types">The list of all serialized types.</param>
-    public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, out IEnumerable<Type> types) {
+    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
+    public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, out IEnumerable<Type> types, bool useZip = false) {
       try {
         Serializer serializer = new Serializer(obj, config);
-        Serialize(stream, serializer);
+        if (useZip) {
+          Serialize(stream, includeAssemblies, CompressionLevel.Optimal, serializer);
+        } else {
+          Serialize(stream, serializer);
+        }
         types = serializer.SerializedTypes;
       }
Index: /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs
===================================================================
--- /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs	(revision 12454)
+++ /trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs	(revision 12455)
@@ -218,9 +218,9 @@
 
     /// <summary>
-    /// Deserializes an object from the specified stream.
+    /// Deserializes an object from the specified stream using GZip compression.
     /// </summary>
     /// <param name="stream">The stream.</param>
     /// <returns>A fresh object instance.</returns>
-    public static object Deserialize(Stream stream) {
+    public static object DeserializeWithGZip(Stream stream) {
       try {
         using (StreamReader reader = new StreamReader(new GZipStream(stream, CompressionMode.Decompress))) {
@@ -239,11 +239,36 @@
 
     /// <summary>
+    /// Deserializes an object from the specified stream using Zip compression.
+    /// </summary>
+    /// <param name="stream">The stream.</param>
+    /// <returns>A fresh object instance.</returns>
+    private static object DeserializeWithZip(Stream stream) {
+      ZipArchive zipFile = new ZipArchive(stream);
+      return Deserialize(zipFile);
+    }
+
+    /// <summary>
     /// Deserializes an object from the specified stream.
     /// </summary>
     /// <typeparam name="T">object type expected from the serialized stream</typeparam>
     /// <param name="stream">The stream.</param>
+    /// <param name="useZip">If true, uses zip for decompression, otherwise gzip.</param>
     /// <returns>A fresh object instance.</returns>
-    public static T Deserialize<T>(Stream stream) {
-      return (T)Deserialize(stream);
+    public static T Deserialize<T>(Stream stream, bool useZip = false) {
+      return (T)Deserialize(stream, useZip);
+    }
+
+    /// <summary>
+    /// Deserializes an object from the specified stream.
+    /// </summary>
+    /// <param name="stream">The stream.</param>
+    /// <param name="useZip">If true, uses zip for decompression, otherwise gzip.</param>
+    /// <returns>A fresh object instance.</returns>
+    public static object Deserialize(Stream stream, bool useZip = false) {
+      if (useZip) {
+        return DeserializeWithZip(stream);
+      } else {
+        return DeserializeWithGZip(stream);
+      }
     }
 
