In the project I'm currently working on, I needed to create a XML from a pretty complex XSD Schema. This schema is very complex because has a lot of imports and includes. The logical way to create a Xml from the XSD is running the XSD.EXE tool (that tool is included in Visual Studio 2003) to generate a class hierarchy, and then, after including this generated classes in the project, populate this classes and serialize them to Xml with the XmlSerializer object.
Here comes the problem: XSD.EXE always returned me the error "Specified cast is not valid". After a few research, I had seen that XSD.EXE was not able to support some sympleTypes and also the "xsd:include schemaLocation" in a proper way. I've tryed some other tools with no luck, XSDObjectGen or CodeXS also failed to generate for me an object that I can use to generate my Xml.
The solution for me was a bit strange, but successful anyway... I tryed to generate the object with an installation of Visual Studio 2005 beta that I have in a virtual machine. I ran the XSD.EXE tool with the schema, and in the first try, the tool generated the C# classes properly. I was surprised, but tryed to import the .cs file into my Visual Studio 2003 project. After removing some duplicated values in an enumerated type, it was compiling successfully... And it works very fine!
Now the trouble I have is the DateTime and Boolean types are non serializing like I need, boolean values are serializing with it's literal value 'true' - 'false' instead of '1' - '0', and the DateTime values are serializing in ISO format, but with the time zone, and I don't need this... But this will be for another article!