I am having trouble to get the code, generated by XSD2Code, to load a supposedly valid xml file.
My test case involves generating C# code for the KML version 2.2.0 schema and trying to load a sample KML file with it.
The exception occuring during this test is the following:
System.InvalidOperationException : There was an error reflecting type 'XSDTest.KmlType'.
----> System.InvalidOperationException : There was an error reflecting property 'NetworkLinkControl'.
----> System.InvalidOperationException : There was an error reflecting type 'XSDTest.NetworkLinkControlType'.
----> System.InvalidOperationException : There was an error reflecting property 'Update'.
----> System.InvalidOperationException : There was an error reflecting type 'XSDTest.UpdateType'.
----> System.InvalidOperationException : There was an error reflecting property 'Items'.
----> System.InvalidOperationException : There was an error reflecting type 'XSDTest.DeleteType'.
----> System.InvalidOperationException : There was an error reflecting property 'Items'.
----> System.InvalidOperationException : There was an error reflecting type 'XSDTest.PlacemarkType'.
----> System.InvalidOperationException : There was an error reflecting property 'author'.
----> System.InvalidOperationException : There was an error reflecting type 'XSDTest.atomPersonConstruct'.
----> System.InvalidOperationException : There was an error reflecting property 'Items'.
----> System.InvalidOperationException : Type of choice identifier 'ItemsElementName' is inconsistent with type of 'Items'. Please use array of System.Collections.Generic.List`1[[XSDTest.ItemsChoiceType, XSDTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
This happens while creating the XML serializer, within the auto generated code:
new System.Xml.Serialization.XmlSerializer(typeof(KmlType))
When creating the code with XSD2Code, I only changed 3 valeus from their default value of false, to true: Serialization.Enabled, Serialization.EnableEncoding and Serialization.GenerateXmlAttributes.
I am not looking for alternatives as far as loading KML with C# is concerned, but I am looking at a way to automatically generated C# code from a valid schema. It doesn't need to be XSD2Code, so in case there's something more appropriate, feel free to suggest that.
Thanks for your help