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

Deserialization of base class

Good afternoon everyone. I'm running into a problem deserializing a stream
using the XmlSerializer. A stored procedure returns the following from SQL
Server:

<Student StudentId="1" Status="1" Gpa="3.50">
<Person Id="1" FirstName="FirstName0" LastName="LastName0"
MiddleInitial="W"/>
</Student>

In my code, person is the base class and student extends it. When I
instantiate the XmlSerializer I use the following overload: XmlSerializer (
Type, Type [ ] ). The first parameter is the derived type, Student. The
second parameter, the Type [ ] contains the base type, Person.

The student information deserializes correctly into a student object.
However, all of the base properties are not populated. I have tried using
the XmlInclude decoration on the base class, directing it to include Student
as a viable type. That also has not worked. All of the properties in both
classes are public, and if I try to deserialize an instance of Person from
Xml it works perfectly.

Has anyone run into this before? Does anyone know how to get around the
problem short of implementing IXmlSerializable on the derived class?

Thanks everyone.
Jan 19 '06 #1
0 1061

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

Similar topics

3
by: TEK | last post by:
There seems to be a bug when deserialization some classes in the .NET framework. If you try to deserialize a class that has a base class that holds a struct with a member that is implementing...
2
by: MP | last post by:
Hello, I am having a bit of a problem with Deserialization. I need to "override" the special constructor used when an object is deserialize. In thes constructor I have to execute some code that...
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...
3
by: Peter | last post by:
Hi, I have created several classes,one act as a base class,all the others inherits from it. The base class contains many complex datas(some properties,arrays and structures). Now I want to...
8
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a...
1
by: Brian Richards | last post by:
I have an object that I'm serializing (binary) that contains other internal objects that are also serialized. The Object contains two other member objects (let's call them source, and depend) one...
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...
5
by: Ruben | last post by:
Hi! Is there a way to figure out, if the constructor or the Set-methods of fields are called by the XML-deserilization or by other calls? I would like to bind special behaviour to my class...
7
by: Andrew | last post by:
Hi, I am using DataContractJsonSerializer to deserialize JSON string in C# objects but I am having a problem. Suppose I have a class: class Item { public ItemId Id { get; set; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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
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...
0
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,...
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.