I have a problem with generating code from xsd with Xsd2Code. The xsd looks like this:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:CountryIdentificationCode-1.0"
xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:LocationIdentificationCode-1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig.xsd" />
.......
</xs:schema>
The error I fet when I try to serialize the instance of a generated class:
"Cannot serialize object of type 'MyXSD.SignatureValueType'.
Consider changing type of XmlText member 'MyXSD.SignatureValueType.Value' from System.Byte[] to string or string array."
The error happens here:
[System.Xml.Serialization.XmlTextAttribute(DataType = "base64Binary")]
public byte[] Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
}
}
Event if I change that attribute to:
[System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
..i get other error:
Type of choice identifier 'ItemsElementName' is inconsistent with type of 'Items'.
Please use array of System.Collections.Generic.List`1[[MyXSD.ItemsChoiceType2, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
Did anybody successfully use Xsd2Code with xmldsig? If possible I would rather solve this with Xsd2Code generator and not manually. Is there any other option?
In Xsd2Code options, set option 'CollectionObjectType' as 'Array' instead of 'List'.