473,698 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Seri alization.XmlRo otAttribute("th ing",
Namespace="urn: thing", IsNullable=fals e)]
public class thing
{
public string name;
}
}
namespace B
{
public class thingUser : A.thing
{
public void doStuffwiththin g();
}
}

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

TIA

Mark

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

public class thingUser : A.thing
{
public void doStuffwiththin g();
Did you mean
public void doStuffwiththin g() {}
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 doStuffwiththin g();


Did you mean
public void doStuffwiththin g() {}
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*******@discu ssions.microsof t.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
1624
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 i don't have control on the xml structure, I tried using the xmlAttributeOverrides class, to instruct the serializer. I was able to override the attributes for the root element, but I'm having problems understanding how to deserialize arrays.
1
6018
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 characters, like changing ampersand to & Here is my code: ---- start of code -------- MyClass *myClass = MyClass() ; XmlSerializer *xs = new XmlSerializer( __typeof( MyClass ) ) ;
3
8047
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
8491
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. I, too, am getting nasty FileNotFound exceptions. I've read, and digested the article, and I think I've found a bug -- it's difficult to track, though it does happen often.
1
1266
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 don't have control on the xml structure, I tried using the xmlAttributeOverrides class, to instruct the serializer. Looks like I'm doing something basically wrong, since I fail to do that even with a very simple example. I would be delitaed if...
1
1253
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 XmlSerializer, great! Now here is my problem. let say my document conceptually map to classes like that: public class Foo
0
1084
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 generated by the XmlSerializer. The JIT compiler gives an error when trying to process the following attribute: - . To make matters worse, this problem is intermittent. I have seen various
175
8805
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 changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
5
7253
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 NumericSettings NumericSettings { get { return _numericSettings; } }
0
9021
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...
1
8892
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
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...
1
6518
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
5860
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
4361
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2323
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
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.