Xsd2Code Deserialize problem

Jan 30, 2015 at 12:48 AM
I received an xsd file and a matching xml file from a client. I used VS2012 with the Xsd2Code plugin to generate classes.

After setting XmlRoot on the class in question in the generated code to deal with a namespace problem, when I call LoadFromFile, I get back an object populated with nothing. No errors. Just a blank object where every field is 0 or null.

Can anyone suggest what might be happening here? With no error message and no code visibility, I'm left guessing.

Jan 30, 2015 at 12:57 AM
Edited Jan 30, 2015 at 3:02 AM

I discovered the problem. I needed to mark each generated class with an XmlType attribute. Once I marked each class with this, it began to populate them. When I told the code generator to include XmlAttributes, it appeared to include incorrect XmlRoot and XmlType data. So I turned off that switch and filled it in myself. Things are working much better now.