.Net SvcUtil: attributes must be optional
- by Michel van Engelen
Hi,
I'm trying to generate C# code classes with SvcUtil.exe instead of Xsd.exe. The latter is giving me some problems.
Command line:
SvcUtil.exe myschema.xsd /dconly /ser:XmlSerializer
Several SvcUtil problems are described and solved here:
http://blog.shutupandcode.net/?p=761
One problem I can't solve is this one: Error: Type 'DatafieldDescription' in namespace '' cannot be imported. Attributes must be optional and from namespace 'http://schemas.microsoft.com/2003/10/Seri
alization/'. Either change the schema so that the types can map to data contract types or use ImportXmlType or use a different serializer.
'
I changed
<xs:attribute name="Order" use="required">
to
<xs:attribute name="Order" use="optional">
and
<xs:attribute name="Order">
But the error remains. Is it possible to use attributes, or do I have to delete them all (in that case, this excercition is over)?