I had what turns out to be a fairly common error the other day when trying to deserialize an xml file in one of my applications. Here is the code I was running:
XmlSerializer ser = new XmlSerializer(typeof(MyObject));
XmlReader xRdr = XmlReader.Create(new StringReader(xmlData));
MyObject tvd = (MyObject)ser.Deserialize(xRdr);
As it turns out this was causing the error: xmlns=''> was not expected during deserialization. Alot of the resources online (including the msdn article here) were pointing me to the namespaces not being the same on the serializer and document. I am not sure why it wasn't working for me because I was playing around with the namespaces but couldn't seem to figure out how to get that working. Maybe because I was only serializing a fragment of a document I'm not sure. Anyway it turns out that specifying the XmlRootAttribute in the XmlSerializer constructor fixed the problem for me. This Stack Overflow article really helped Here is the snippet of code that I am using now:
XmlRootAttribute xRoot = new XmlRootAttribute();
xRoot.ElementName = elementName;
xRoot.IsNullable = true;
XmlSerializer ser = new XmlSerializer(typeof(MyObject), xRoot);
XmlReader xRdr = XmlReader.Create(new StringReader(xmlData));
MyObject tvd = (MyObject)ser.Deserialize(xRdr);
Hope this helps

Comments