Tuesday, August 3, 2010

XSD.exe not able to generate C# classes when the schema uses imports

XSD.Exe is unable to generate C# classes when an import function is used to use the existing types from another schema. It throws a warning like
Schema could not be validated. Class generation may fail or may produce incorrect results.
Solution : Copy the imported schema(Schema with reuse types) to the same folder as the schema which is using its types and also don't use the reference when importing to get to the reusable types instead use the schema which is copied to the local folder and then execute the following command.

Xsd.exe NewSchema.xsd SchemaWithReuseTypes.xsd /c this should generate the corresponding c# class.

No comments: