Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

XMLSerializer--how to debug?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry Bud - 29 Feb 2008 19:42 GMT
I've got 2 XSD files which I've converted to classes with the xsd.exe
tool.  I've created the first XMLSerializer object just fine, but the
2nd throws an exception when creating from the root class:

deserializer = New XmlSerializer(GetType(myrootclass))

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

There's about 50 classes in this class file.  I've gotten part of the
way down the tree so I can try to identify exactly what is throwing
this (and what it really means), but is there a better way, and more
importantly, how bad is XSD.exe in creating a class file that doesn't
serialize?
Peter Bromberg [C# MVP] - 29 Feb 2008 21:28 GMT
You might want to look into "XSDObjectGen":
http://www.microsoft.com/downloads/details.aspx?FamilyID=89E6B1E5-F66C-4A4D-933B
-46222BB01EB0&displaylang=en

This is a little more full-featured than XSD.EXE and gives you more control.
There are a few others like this also, including one on sourceforge.
Unfortunately I must be having a Senior Moment, can't remember the name.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> I've got 2 XSD files which I've converted to classes with the xsd.exe
> tool.  I've created the first XMLSerializer object just fine, but the
[quoted text clipped - 11 lines]
> importantly, how bad is XSD.exe in creating a class file that doesn't
> serialize?
Larry Bud - 03 Mar 2008 13:12 GMT
On Feb 29, 4:28 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.com> wrote:
> You might want to look into "XSDObjectGen":http://www.microsoft.com/downloads/details.aspx?FamilyID=89E6B1E5-F66...
> This is a little more full-featured than XSD.EXE and gives you more control.
[quoted text clipped - 20 lines]
> > importantly, how bad is XSD.exe in creating a class file that doesn't
> > serialize?

Is it possible to step through the creation of the serializer object?
Kieran Coughlan - 15 Apr 2008 10:45 GMT
> I've got 2 XSD files which I've converted to classes with the xsd.exe
> tool.  I've created the first XMLSerializer object just fine, but the
[quoted text clipped - 5 lines]
> 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:

<ConstraintList>
 <Constraint>
   <Test .... >
   <Test .... >
 </Constraint>
 <Constraint>
  : : : :

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[][] constraintField".
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, changing
the .cs file manually to that it was simply "private Test[] constraintField"
(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.

K
Larry Bud - 15 Apr 2008 13:17 GMT
On Apr 15, 5:45 am, Kieran Coughlan <Kieran
Cough...@discussions.microsoft.com> wrote:
> > I've got 2 XSD files which I've converted to classes with the xsd.exe
> > tool.  I've created the first XMLSerializer object just fine, but the
[quoted text clipped - 35 lines]
>
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.