Re: XMLSerializer--how to debug?
am 15.04.2008 14:17:00 von Larry BudOn Apr 15, 5:45=A0am, Kieran Coughlan
> "Larry Bud" wrote:
> > I've got 2 XSD files which I've converted to classes with the xsd.exe
> > tool. =A0I've created the first XMLSerializer object just fine, but the
> > 2nd throws an exception when creating from the root class:
>
> > deserializer =3D New XmlSerializer(GetType(myrootclass))
>
> > Unable to generate a temporary class (result=3D1). error CS0030: Cannot
> > convert type 'string[]' to 'string' error CS0029: Cannot implicitly
> > convert type 'string' to 'string[]'
>
> I had this error this morning. I had XML which looked like this:
>
>
> =A0
> =A0 =A0
> =A0 =A0
> =A0
> =A0
> =A0 =A0: : : :
>
> etc.
>
> When XSD was creating classes, it was creating a class for Constraint, but=
> not using it in ConstraintList. Where you might expect "private Consraint
> constraintField", instead it was creating "private Test[][] constraintFiel=
d".
> I kinda see where it was coming from, but it wasn't serializing.
>
> For reasons I haven't bothered to try to understand at the moment, changin=
g
> the .cs file manually to that it was simply "private Test[] constraintFiel=
d"
> (and changing the accompaning property as well) meant that it serialized
> fine. It certainly looked alright after a superficial examination of my
> classes in the debugger.
>
> Anyhow, I didn't want to be having to manually edit the .cs everytime I
> regenerated it so I added a dummy attribute to Constraint. As I suspected,=
> was enough to make XSD behave and create the classes as I'd expect
> (ConstraintList now has "private Constraint[] constraintField).
>
> Hope this is some help to someone.
Thanks. My problem turned out to be a poorly designed schema, which
we fixed.
I honestly think few people are doing serialization, as I've had
almost no help when a question has arisen.