472,333 Members | 1,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

serialization problem with a class that derives from dataset


I am working with the beta version of the new .net framework (Whidbey) and I
encountered a problem with serialization that did'nt exist in the .net 2003
the situation is like this :
I have a class that inherits from dataset, and I want to serialize it , so I
created a serialization constructor that forwards the call to the base class
(the dataset) serialization constructor, normally, for this action to
succeed I am supposed to put an attribute on the super class (in this case
the dataset) that looks like that :
[XmlInclude (typeOf (<myClass>))]

so that the serializer will be able to deserialize my class where a dataset
was daclared, the problem is, that I can't put this attribute on the
currrently the serializer is able to serialize my class but when it
desirializes it I get a dataset object and I can't cast it to the derived
class (casting fails),
so I need an alternative way to let the serializer know about the derived
class, so if anyone knows a way to do this without using the attribute I
would appreciate his help.

code sample that demonstrates the situation:

// the derived class

public class MyDataSet : DataSet
public MyDataSet() : base()

// serialization constructor
public MyDataSet(Serialization info,StreamingContext context) :

// serializing the class
MyDataSet ds = new MyDataSet();

XmlSerializer ser = new XmlSerializer(typeof(DataSet));

StringWriter writer = new StringWriter();

ser.Serialize(writer, ds);



// desirializing the class

MyDataSet newDs = new MyDataSet();

StreamReader reader = new StreamReader("Ser.Xml", Encoding.UTF8);

newDs = ser.Deserialize(reader) as MyDataSet; // at this point the casting
fails and returns null.



thanks , ofer.
Jul 21 '05 #1
1 1389

Did you know that there are specialized 2005 newsgroups.



Jul 21 '05 #2

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

Similar topics

by: okinrus | last post by:
Can someone take a look at this code and figure out why Serializable_base::add_serializer throws std::bad_alloc. The problem seems to be the...
by: hs | last post by:
Hi I am serializing a dataset using a binary formatter as follows: IFormatter formater = new BinaryFormatter(); formatter.Serialize(stream, ds);...
by: Aaron Clamage | last post by:
Hi, I'm not sure that if this is the right forum, but any help would be greatly appreciated. I am porting some java serialization code to c#...
by: Aaron Clamage | last post by:
Hi, Could someone please confirm the following? I think I have found a subtle .NET serialization bug. It occurs when object has a list of...
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in...
by: tony lock | last post by:
I have a class inherited from Control, which I want to serialize, since Control is not Serializable, I have had to implement ISerializable. This...
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in...
by: Joe | last post by:
I've tracked the performance issue down to a single class. This class derives from CollectionBase and stores a basic value type such as string,...
by: Paez | last post by:
Hi There. This post is a extension of thread "Serialize or not to Serialize", on 5 of December of 2006. The reason why my teacher insists that...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.