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 / .NET Framework / XML / March 2007

Tip: Looking for answers? Try searching our database.

XML/SOAP Serilaiztion and Generic Collections

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DXRick - 29 Mar 2007 23:34 GMT
I have a class (UserAccount) that uses a List<T> to contain a collection of
Account classes.  The Account class uses a List<T> to contain a collection of
the account items.  If the Account class is a checking account its List<>
collection contains instances of the CheckItem class, which represents a
single register item in a checking account.

I would like to be able to use the three types of serialization on them.  Of
course, the BinaryFormatter works fine.  I tried to mark the List<> fields as
[SoapIgnore, XmlIgnore] and before XML or SOAP seriliazation create an Array
from it.  However, the mere existence of the List<> class still causes XML
and SOAP seriliazation to fail, claiming that generics are not supported.

Is there a way I can use the generic List<> collection and still get XML and
SOAP serialization to work?

Thanks!
DXRick - 31 Mar 2007 04:36 GMT
Well, should I.....

1) Use an ArrayList instead?

2) Use a XMLWriter to create a XML version of the class's contents?

I do not intend to deserialize it, but rather to support XML and SOAP as
formats to export the data too.

Anyone????

TY
Joe Fawcett - 31 Mar 2007 08:04 GMT
There are two issues, firstly, as you say, the soap formatter cannot cope
with generics. Secondly you can still serialise to XML using XmlSerializer
directly.

Signature

Joe Fawcett (MVP - XML)
http://joe.fawcett.name

>I have a class (UserAccount) that uses a List<T> to contain a collection of
> Account classes.  The Account class uses a List<T> to contain a collection
[quoted text clipped - 17 lines]
>
> Thanks!

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.