ServiceStack/ServiceStack.Text — Issue #46: XmlSerializer.SerializeToString() fails with a "Cannot access a closed Stream." exception
Author: jamesmcginty
Created: 2011-11-08 05:18:13+00:00
State: open

using System;
using ServiceStack.Text;
using System.Runtime.Serialization;

namespace XMLSerialiserTest
{
[DataContract]
public class PersonRecord
{
public int Id { get; set; }
public string Name { get; set; }
}

class Program
{
static void Main(string[] args)
{
var p = new PersonRecord {Id = 27, Name = "John"};

// Fails at this point, with a "Cannot access a closed Stream." exception.
// Am I doing something wrong?
string output = XmlSerializer.SerializeToString(p);

Console.WriteLine(output);
}
}
}