Wednesday, April 17, 2013

XMLNodeReader problem: The specified type was not recognized



// Solves the "The specified type was not recognized: name='##', namespace='##', at ..."
    // Came across this when trying to serialize an object of a custom type
    // It is caused due to a missing namespace reference (for some reason, the LookupNamespace method in the reader
    // does not return a string from the NameTable)
    public class XmlNodeReader2 : XmlNodeReader
    {
        public XmlNodeReader2(XmlNode node)
            : base(node)
        {
        }

        public override string LookupNamespace(string prefix)
        {
            return NameTable.Add(base.LookupNamespace(prefix));
        }

        
    }

source:http://coderstuff.blogspot.nl/2005/10/xmlserializer-bug-when-xsitype-is-used.html