473,396 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XmlSerializer and nested ArrayLists

Have a class with a public property named "TheFirstPropertyOfArrayListType"
of type ArrayList, property has attribute XmlElement to describe the
contents of the ArrayList, the contents is a public class with attribute
XmlSerializable.
This "second level" class named "SecondClass" has an attribute of type
XmlSerializable, a public property of type ArrayList, with attribute
XmlElement to describe the contents of the ArrayList, the contents is a
public class (ThirdClass, se below) with attribute XmlSerializable.
This "third level class named "ThirdClass" has three public properties of
simple types (string, string and bool).

Both the SecondClass and the ThirdClass har default constructors and they
inherit from object only

When I try to serialize the property (see first line in this post) with:
:
XmlSerializer serializer = new
XmlSerializer(TheFirstPropertyOfArrayListType.GetT ype());
XmlTextWriter xmlWriter = new XmlTextWriter("test.xml", Encoding.UTF8);
serializer.Serialize(xmlWriter, TheFirstPropertyOfArrayListType);
xnlWriter.Close();

When this is executed an exception of type
'System.InvalidOperationException' occurred in system.xml.dll
This is thrown in the Serialize method.
Message: Additional information: The type Second was not expected. Use
XmlInclude or SoapInclude to specify types that are not known statically.

Class Second is not created by Reflection so it should be known "statically"
(??)

can anyone tell me what is wrong ? Is it not possible to serialize an
ArrayList containing other ArrayLists containing a class ?
Nov 12 '05 #1
0 1991

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

Similar topics

0
by: Alexandros__ | last post by:
Hello everyone, I am using the Configuration Application block to write an XML configuration file for my application. Most of it is working fine but I have a problem serialising some nested...
5
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...
2
by: magister | last post by:
Hello I got this working but it is not how I really want it, basically I have an xml file which has a root of <test> and can be filled with 3 different types of <question> elements with different...
1
by: Jamus Sprinson | last post by:
Before I continue, I'm going to begin by saying I'm not by any means an expert- I've been using .NET with C# for about 4 months now, and basically just learning by example and docs. A game...
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
2
by: Steve | last post by:
I'm an XML newb. I'm serializing a class and when I inspect the xml file, all the data is on one line rather than being nested and indented Is that normal? <code> StreamWriter sw = new...
5
by: drdave | last post by:
I would like to have ten arraylists created within a loop.. is there a conversion or something I can do to acheive this.. pseudo: Dim counter As Integer = 0 Dim ArrName As ArrayList ...
3
by: steve | last post by:
I need to compare the value of a field in a row on an arraylist with the value of a field on a second arraylist I have this bit of code working for arrays but cant get it working for arraylists The...
1
by: JonBeatty | last post by:
I am trying to serialize a class derived from ArrayList called JobQueue that contains an array of objects of the class Job. Using XmlSerializer I can get this to serialize successfully, but I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.