473,624 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLSerializer - Using CollectionBase

I'm using XMLSerializer to serialize a hierarchy of class-based objects to
XML. So far, this is working successfully by employing arrays to handle the
multiplicity of child objects. However, I'm trying to employ the use of
collection classes instead because there are methods I need to implement at
that level. But when I instantiate the XMLSerializer, it gives the error:
There was an error reflecting <Root Type>. If I try using

<XmlArrayAttrib ute(<child object type>)Public ...

I get the same error.

Is it possible to implement collection classes that the XMLSerializer will
work with, or do I have to stick with arrays? Thanks.
Nov 17 '06 #1
1 1720
"Phil Galey" <pa*****@starca lif.com.nospamw rote in message
news:eK******** ********@TK2MSF TNGP06.phx.gbl. ..
I'm using XMLSerializer to serialize a hierarchy of class-based objects to
XML. So far, this is working successfully by employing arrays to handle
the
multiplicity of child objects. However, I'm trying to employ the use of
collection classes instead because there are methods I need to implement
at
that level. But when I instantiate the XMLSerializer, it gives the error:
There was an error reflecting <Root Type>. If I try using
Look closely at the error it's returning you. If you're not displaying the
entire exception, then do so. You need to see the InnerException property.

There are constraints on the collections you can use, but the exception
message will tell you what it wants you to do. I couldn't enumerate them for
you, however, I went through the same process and now use collections all
over the place and serialize them to XML just fine.

John
Nov 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5414
by: Stuart Robertson | last post by:
I am trying to find a solution that will allow me to use XmlSerializer to serialize/deserialize a collection of objects where a given object is shared between two or more other objects, and not create duplicate XML representations of the shared object, but instead use IDREFs to refer to the shared object. The XML I'm trying to produce is as follows (where "href" is an IDREF): <?xml version="1.0" encoding="utf-8"?> <MyRootClass...
8
3561
by: Harris Boyce | last post by:
Hello, I'm trying to use the FOR XML EXPLICIT clause with SQL Server to deserialize data from my database into a strongly-typed collection object that I will use throughout my application. I initially tested my design by building a collection in code and then serializing it to/from an XML file, which worked fine. However, I have hit a brick wall trying to restore the data from SQL Server. I originally had my collection and object
2
1781
by: eastsh | last post by:
I have been looking into using the MS application block for configuration management, and I am very happy with the options it provides. Since it stores hashtables, I decided that for configuration data my app needs, I would create strongly typed collections for each config type. For instance, CarCollection dervied from CollectionBase which only accepts items of Car would be set to hashtable key "AppCars". I am running into all kinds of...
4
11369
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This should have worked fine since the class in question was already being serialized and deserialized as part of a Web service interface. What I found was that by deserializing from an XmlNodeReader instead of an XmlTextReader, XML Serialization doesn't work...
2
6802
by: Kent Boogaart | last post by:
Hello all, I have two simple classes: Item and ItemCollection. Item stores a label for the item and an instance of ItemCollection for all child items. ItemCollection just stores a collection of Items. ItemCollection implements System.Collections.ICollection. When I use XmlSerializer to serialize an instance of ItemCollection, I am unable to control the element names used to contain the item collection and the items therein. Applying...
3
4506
by: Loui Mercieca | last post by:
Hi, I have created a class, named FormField , which basically contains two fields, name and value. I have set the tag before the class and the field is set as an XmlAttribute whil the name as XmlText. In my main class, i have created an arraylist which contains a collection of this class FormField. Basically its: public void Add( string sName, string sValue )
0
1087
by: Charles Law | last post by:
I use the XMLSerializer to serialise an object called SuperClass, and I get something like this <SuperClass> <Classes> <SomeName xsi:type="MyClass1"> </SomeName> <SomeName xsi:type="MyClass2"> </SomeName> <SomeName xsi:type="MyClass2">
0
1070
by: Phil Galey | last post by:
I have XMLSerializer successfully serializing a collection class that inherits CollectionBase. My reason for doing it this way instead of using an XMLArrayAttribute is that I need to be able to add an XMLAttribute at the group level. Although the group object and child objects serialize fine to XML, the extra property I added to the collection class is ignored. I've tried declaring it with and without the <XmlAttributeAttribute()tag,...
2
2331
by: bmomalley | last post by:
Hi Folks, I need help, because I am just at a loss. I'm not super comfortable with XML, but I'm trying to fight my way through generating an RSS XML file for Google Base, and I'm stuck with a Namespace issue. How can I get XmlSerializer to generate the standard RSS tags with no prefix, but ensure that the Google specific tags a prefixed with "g:"? Here's a sample of the code I'm using, and it puts g: in front of ALL
0
8677
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8620
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.