[Solved-3 Solutions] XmlSerializer - There was an error reflecting type
- Using C# .NET 2.0, we have a composite data class that does have the
[Serializable]attribute on it. When we create an
XMLSerializerclass and pass that into the constructor:
- We get this exemption saying:
There was an error reflecting type.
- Look at the inner exception that you are getting. It will tell which field/property it is having trouble serializing.
- We can exclude fields/properties from xml serialization by decorating them with the
- Serialized classes must have default (i.e. parameter less) constructors. If we have no constructor at all, that's fine; but if we have a constructor with a parameter, we'll need to add the default one too.
- All the objects in the serialization graph have to be serializable.
XMLSerializeris a black box, check these links if you want to debug further into the serialization process.
Changing where XmlSerializer Outputs Temporary Assemblies
HOW TO: Debug into a .NET XmlSerializer Generated Assembly