This is a really crazy bug. The following is throwing an OutOfMemoryException
, for XML snippits that are very short and simple (e.g., <ABC def='123'/>
):
public static T DeserializeXmlNode<T>(XmlNode node)
{
try
{
return (T)new XmlSerializer(typeof(T))
.Deserialize(new XmlNodeReader(node));
}
catch (Exception ex)
{
throw; // just for catching a breakpoint.
}
}
I read in this MSDN article that if I were using XmlSerializer with additional parameters in the constructor, I'd end up generating un-cached serializer assemblies every time it got called, causing an Assembly Leak. But I'm not using additional parameters in the constructor. It also happens on the first time it is called in a freshly started AppDomain, so that doesn't make sense either.
What gives?