473,597 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlSerializer with object derived from CollectionBase

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 hurdles trying to get the hashtable
serialized. The app block takes care of converting the hashtable to an
XmlNode collection I believe, but I am wondering what is going on with
my collection. I guess my questions would break down as this:

1. Is it recommended that XmlSerializer be used to store collection
objects that derive from CollectionBase and contain strongly typed values?

2. Are there any articles that would help me?

I have read enough to know that XmlSerializer wants a public property
"Count" of type int, and a public Indexer for the collection which has
to return the same type that Add requires, which I took care of.

Any suggestions? Seems like a reasonable thing to me..
Nov 12 '05 #1
2 1778
I do not think that the XmlSerializer supports hashtables. See this thread:

http://groups.google.com.au/groups?h...BXmlSerializer

--
Ross Donald
Rad Software
Free Regular Expression Designer @
http://www.radsoftware.com.au/web/Products/
"eastsh" <as*@forit.co m> wrote in message
news:yG******** ************@tw ister.tampabay. rr.com...
| 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 hurdles trying to get the hashtable
| serialized. The app block takes care of converting the hashtable to an
| XmlNode collection I believe, but I am wondering what is going on with
| my collection. I guess my questions would break down as this:
|
| 1. Is it recommended that XmlSerializer be used to store collection
| objects that derive from CollectionBase and contain strongly typed values?
|
| 2. Are there any articles that would help me?
|
| I have read enough to know that XmlSerializer wants a public property
| "Count" of type int, and a public Indexer for the collection which has
| to return the same type that Add requires, which I took care of.
|
| Any suggestions? Seems like a reasonable thing to me..
Nov 12 '05 #2
I do not think that the XmlSerializer supports hashtables. See this thread:

http://groups.google.com.au/groups?h...BXmlSerializer

--
Ross Donald
Rad Software
Free Regular Expression Designer @
http://www.radsoftware.com.au/web/Products/
"eastsh" <as*@forit.co m> wrote in message
news:yG******** ************@tw ister.tampabay. rr.com...
| 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 hurdles trying to get the hashtable
| serialized. The app block takes care of converting the hashtable to an
| XmlNode collection I believe, but I am wondering what is going on with
| my collection. I guess my questions would break down as this:
|
| 1. Is it recommended that XmlSerializer be used to store collection
| objects that derive from CollectionBase and contain strongly typed values?
|
| 2. Are there any articles that would help me?
|
| I have read enough to know that XmlSerializer wants a public property
| "Count" of type int, and a public Indexer for the collection which has
| to return the same type that Add requires, which I took care of.
|
| Any suggestions? Seems like a reasonable thing to me..
Nov 12 '05 #3

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

Similar topics

8
3557
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
4
11364
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
6800
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
4503
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 )
2
3190
by: bughunter | last post by:
This is partly 'for the record' and partly a query about whether the following is a bug somewhere in .Net (whether it be the CLR, JITter, C# compiler). This is all in the context of .Net 1.1 SP1. Recently we (my fellow team members & I) observed an InvalidOperationException - 'collection has been modified', however it wasn't immediately obvious why this would be occuring. There are no modifications occuring within the loop and there is...
0
1167
by: Craig Buchanan | last post by:
I have an Application object that i use to open saved instances of a variety of derived classes (a factory method). Each derived-class instance is based on a MustInherit base class. Here's a code snippet: Public Function Open(ByVal source As String) As MyBaseClass ... Dim XS As XmlSerializer = New XmlSerializer(GetType(MyBaseClass)) 'error on this statement if i use GetType(MyBaseClass); no error if i
1
5112
by: Yewen Tang | last post by:
I have a schema file datamodel.xsd, element "properties" is declared as a type of "baseProperty". The schema file also defines "derivedProperty" is a derived type of "baseProperty". <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:myns="uri:myschema" targetNamespace="uri:myschema" elementFormDefault="qualified" version="1.0"> <xs:complexType name="derivedProperty">
1
1716
by: Phil Galey | last post by:
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 ...
4
2386
by: Olivier Matrot | last post by:
Hello, I'm still using old style strongly typed collections (derived from CollectionBase .NET 1.1) and I would like to be able to query in memory collection with LINQ in the future. I also would like to improve performance of the collection avoiding boxing/unboxing of objects during access of items in the collection. Could you please point me to the right direction ? TIA.
0
8381
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...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6687
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
5847
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
5428
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3923
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2403
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
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1233
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.