473,508 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deep Copy via Serialization

Hi,

I've tried to to a deep copy of an serializable object (generated by
creating a xml Schema and then genrate classes with xsd.exe) using
serialization (xmlSerializer)
When I'm using a memory stream to serialize and deserialize, it fails
when trying to deserialize it (at position {0,0}
But when I'm using a file stream (store the file to c:\temp) and
desierialize it, it works just fine.

Why? Whats wrong with the memory stream? Known serialization bug?
/Magnus

Apr 10 '06 #1
5 2011
Iv'e done this successfuly a long time ago using binary formatter and a
memorystream.

I then discontinued the practice after finding several problems
(including speed of execution).

I prefere instead to use the method pointed out here:
http://www.agiledeveloper.com/articl...ning072002.htm

This particular concept is working very well and the code running under
it is fast(ish) and very stable.

-dm

Apr 10 '06 #2
Thanks fo the tip, but the auto generated code does not implement the
IClonable interface... (?)
Maybe it's possible to use the partial class concept to implement
IClonable in a partial part of the autogenerated code...

And I do not want to create a copy constructor to set sometimes lots
and lots of property values

/Magnus

Apr 10 '06 #3

"Magnus" <su*****@hotmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
Thanks fo the tip, but the auto generated code does not implement the
IClonable interface... (?)
Maybe it's possible to use the partial class concept to implement
IClonable in a partial part of the autogenerated code...


Unless the autogenerated uses "partial" that wont work without some sort of
hack because ALL partial parts of a class must declare it as partial :-(
Apr 10 '06 #4
Yes i know, and the autogenerated code from xsd do declare the classes
as partial.

But do all partial classes need to declare the base class and/or
interfaces?
The question is if it is possible to add some interfaces and or a base
class to a autogenerated partial class?
This must be really easy to test :-)

/Magnus

Apr 10 '06 #5
Adding an interface to one of the partial classes was enough for the
compiler to accept the whole class...
But it is still boring and time consuming to copy all property fields
with the IClonabe and copy constructor combination...
I still want a generic solution...

/Magnus

Apr 10 '06 #6

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

Similar topics

13
2164
by: ahaupt | last post by:
Hi all, I'm implementing the Clone() method through the ICloneable interface and don't quite know how deep I need to go for a deep copy. Example: class A: ICloneable { object _val;
1
2320
by: oDDskOOL | last post by:
I realized today that the Hashtable.Clone only produces a shallow copy... that makes me go mad that M$ doesn't even provide a deep copy ctor for the Hashtable class ! mighty tech ducks might...
5
25629
by: BenW | last post by:
Hello, What is the easiest way to make "deep copy" of my Hashtable? How about with other Collection classes in C#, any documents available? I don'r actually understand why Framework's...
4
3023
by: jjkboswell | last post by:
I have an XSD which I have generated a class from using the xsd.exe tool. My XSD contains complex types within it, so that the generated class has member variables which are of types that are also...
3
8739
by: raylopez99 | last post by:
The "C# Cookbook" (O'Reilly / Jay Hilyard), section 3.26, is on deep cloning versus shallow cloning. The scanned pages of this book are found here: http://www.sendspace.com/file/mjyocg (Word...
0
7120
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
7380
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
7494
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
5626
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,...
1
5050
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...
0
4706
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...
0
3192
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
415
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...

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.