public void Execute() { var serializer = new XmlSerializer(typeof(XmlSerializerSamples01_Data)); var original = new XmlSerializerSamples01_Data(); original.Initialize(); using (var mem = new MemoryStream()) { serializer.Serialize(mem, original); mem.Position = 0; mem.CopyTo(Output.OutStream); } }