XSD.exe throwing out ‘Unable to generate a temporary class (result=1). error CS0030: Cannot convert type’

Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'SomeType[]' to 'SomeType'
error CS0029: Cannot implicitly convert type 'SomeType' to 'SomeType[]'

If you're using xsd.exe to generate proxy classes and getting the above error, it has something to do with a bug on xsd.exe for not correctly handling multidimensional array in the generated class.

If you are indeed expecting a multidimensional array, find the multidimensional array property and change typeof(SomeType) to typeof(SomeType[])

for.eg

[System.Xml.Serialization.XmlArrayItemAttribute("SomeType", typeof(SomeType[]), IsNullable=false)]
public SomeType[][] PropertyName

If you're generating the xsd from the xml, it could be that you're not really expecting a multidimensional array. So, we want to do the opposite to remove the type of the property to single dimension array.

for e.g

[System.Xml.Serialization.XmlArrayItemAttribute("SomeType", typeof(SomeType), IsNullable=false)]
public SomeType[] PropertyName

I am on .Net 3.5 VS2010.

  1. Andrew Mackay says:

    Hey Ron, I have experienced this before when working with the OTA (www.opentravel.org) XML schema which uses a jagged arrays (arrays of arrays). We were using Biztalk and used to experience bits of XML not serialising/deserialising. Had to hack it but cant remember now how we got over it. Andrew

  2. ronaldwidha says:

    I remember I have had the same error in the past and I might have done the hack that I mention above (changing the generated proxy class). It's not pretty but it works. Thanks for leaving a note