I think that closing the XmlTextWriter will also close the MemoryStream that it is using.
Also, where is your MemoryStream declared? is it closed before you use it it XmlTextWriter?
maybe something like this will work better...
using(MemoryStream ms = new MemoryStream())
{
using(XmlTextWriter xmlwr = new XmlTextWriter(ms,System.Text.Encoding.UTF8))
{
ms.Position = 0;
XmlDocument x = new XmlDocument();
x.Load(ms);
}
}