Home > Uncategorized > C# Unable to generate temporary classes

C# Unable to generate temporary classes


Error: xml read c# error CS0030: Cannot convert type ‘[]’ to ‘string’

Solution:

You are running into a known problem in XmlSerializer Code Generation component: it cannot handle some cases of nested unbounded elements.  The Object Model it creates is not valid: user cannot use it to produce xml messages.

Unfortunately to fix this you have to edit your schema to make sure that all array-like constructs will be handled properly.

 

You would need to slightly modify all schema constructs that have the following:

<xs:sequence maxOccurs=”unbounded”>

  <xs:element ../>

<xs:sequence>

 or

<xs:sequence>

  <xs:element maxOccurs=”unbounded”/>

<xs:sequence>

 

 

Have to be changed to

 

<xs:sequence maxOccurs=”unbounded”>

  <xs:element ../>

<xs:sequence>

<xs:attribute name=”tmp” type=”xs:string” />

And

<xs:sequence>

  <xs:element maxOccurs=”unbounded”/>

<xs:sequence>

<xs:attribute name=”tmp” type=”xs:string” />

 

Adding attribute will force XmlSerializer code generator using a class with array member and proper XmlSerialization attributes for the construct instead of an unwrapped array.

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: