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

XMLSerializer & Inheritence

Help!

I want to serialize mu C# objects uzing the xmlserializer
class. It works well whem all my classes are flat, but
when I use inheritence to split the data and
implementation I get an "unknown element" exception.

namespace A
{
[System.Xml.Serialization.XmlRootAttribute("thing",
Namespace="urn:thing", IsNullable=false)]
public class thing
{
public string name;
}
}
namespace B
{
public class thingUser : A.thing
{
public void doStuffwiththing();
}
}

I want to deserialize B.thingUser but it fails! How do I
get round this?

TIA

Mark

Nov 11 '05 #1
3 1458
Mark Turner wrote:

public class thingUser : A.thing
{
public void doStuffwiththing();
Did you mean
public void doStuffwiththing() {}
I want to deserialize B.thingUser but it fails! How do I
get round this?


--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
The example was retyped for clarity, pointing out a
typing mistake is hardly helpful!

basically the problem is with the XmlSerializer getting
its knickers in a twist. I cant see why it should have a
problem but seemingly if i have the 2 classes named the
same but in different namespaces it has a hard time
figuring out the attributed of the subclass.

any pointers?
-----Original Message-----
Mark Turner wrote:

public class thingUser : A.thing
{
public void doStuffwiththing();


Did you mean
public void doStuffwiththing() {}
I want to deserialize B.thingUser but it fails! How do I get round this?


--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

.

Nov 11 '05 #3
an*******@discussions.microsoft.com wrote:
The example was retyped for clarity, pointing out a
typing mistake is hardly helpful!


I just copied your code and pasted it to VS.NET. Aftetr fixing that typo
I run the serializer on b.thingUser class with no any hitch. When name
property is set it's serialized as b.thingUser member.
Provide more info about exception you are getting.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #4

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

Similar topics

4
by: Zion Zadik | last post by:
Dear all, I have a set of c# data classes which i need to fill their data from xml files. serialization looks to be the best way to accomplish this task. Since the data classes are compiled and...
1
by: Daniel Lim | last post by:
When using XmlSerializer, I notice that it does not normalize the single quote and double quote characters, i.e. does not change ' to ' and " to &quot. However, it does normalize other...
3
by: Cindy Liu | last post by:
Hi, I use XmlSerializer to serialize xml string. It escapes xml special charaters, like < and > to < and >. How can I stop XmlSerializer to escape these charaters? Thanks in advance!!! Cindy
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....
1
by: Zion Zadik | last post by:
Dear all, I have a set of c# data classes wich i need to fill their data from xml files. serialization looks to be the best way to accomplish this task. Since the data classes are compiled and i...
1
by: Lloyd Dupont | last post by:
I get an XmlDocument from an external source. I want to load it/map it to C# class. I'm creating classes as I learn about the format. many tag are yet unparsed, but that seems ok for the...
0
by: Ian Armitage | last post by:
Hi, I am having problems using the XmlSerializer from within a signed assembly. I have narrowed down the problem to a compilation error (CS0647) occuring when .NET tries to compile code...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
5
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I am using XML serialization for the first time and I have noticed something unexpected. The object I am serializing contains a field private NumericSettings _numericSettings; public...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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,...

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.