473,406 Members | 2,633 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,406 software developers and data experts.

Deserialization of objects containing arrays of unknown size

I have a class which uses three other classes, two of which are used in
arrays. This class is only ever used for incoming messages. All classes
inherit from ISerializable and impliment GetObjectData(). All classes use
the [Serializable] attribute and have a default constructor.

When deserializing from an xml string that represents a complex object, I am
getting NullReferenceExceptions that seem to be related to the arrays. The
object is created using the default constructor so the array sizes are
unknown and not constructed. The content is only populated when deserialized.

Using SerializationInfo in a constructor in the manner
_header=(IspecHeader)info.GetValue("Header",this.H eader.GetType()); does not
seem to populate the child object even for items that are not arrays.

For the arrays I am trying to use code like
_lincList=(IspecRow[])info.GetValue("LincList",this.LincList.GetType()) ; in
the constructor of the parent object.

The assignments in both the above are to private variables that are used by
Properties.

How can I deserialize a complex object? Serialize works just fine at parent
object level for all its children. With deserialization to what extent does
each child class need to handle its serialization and how is it called. I
currently have all classes inheriting from ISerializable, implimenting
GetObjectData() and an Overloaded constructor using SerializationInfo and
StreamingContext.

When I Unit Test this the deserialize does not throw an exception.
When I try and access objects that should be populated it throws a
NullReferenceException.

When I try to serialize after a deserialize it returns xml that does not
contain any child information.

I am at a loss and the examples are too simplistic and not real world enough.

Any help would be very much appreciated. I will supply code if required.

cheers

PeterW
Dec 15 '05 #1
0 1175

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

Similar topics

5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
0
by: Dan Noel | last post by:
I am implementing a DataStore/Settings object that stores objects in XML by serializing the objects in XML and then associating these objects with key names. At some later point, I want to...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
2
by: Robert Jacobson | last post by:
Hi, If I have an XML file that stores its data in a hierarchical relationship, is there a way to automatically "flatten" this relationship when I deserialize it (using the XmlSerializer) to a...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
7
by: PeterW | last post by:
I have an xml file containing some stuff. I use xsd to generate a schema and again to create classes from the schemas. added using System, System.IO; added to all classes added namespace ROC...
5
by: Greg Allen | last post by:
I am consuming a web service and using the generated Reference.cs to access the service and the objects associated with it. I have run into a problem where some inherited classes are not being...
1
by: pistmaster | last post by:
Hi, I have a client server application which has various messages containing enums, ie I serialize classes of the form: class MyClass { MyEnum e; }
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
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...
0
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...

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.