473,714 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extending serialization

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# and I can't figure out the
correct way to do it. It seems that either I can use default serialization
or implement ISerializable. Is there any way to do both (e.g. extend the
default serialization). In other words, I want to be able to implement my
custom serialization code but call the default serialization code as well.
In java, I can do this:

private void writeObject(Obj ectOutputStream out) throws IOException {
out.defaultWrit eObject();
//implement my custom code
}

It seems there is no .NET equivalent. In particular I have a class that has
a GraphicsPath member. This class implements ISerializable so that it can
correctly serialize the path. But, for the other members including
references to other objects, I would like to use the default serialization.
Is this possible? Moreover this class derives from a serializable class
that does not implement ISerializable. Does the derived class have to
serialize all of the inherited members as well, if it chooses to do custom
serialization.

Thanks so much,
Aaron
Nov 15 '05 #1
3 3173
To add to/refine this question a bit, is it possible to mix and match custom
and default serialization along an inheritance hierarchy. If a base class
uses custom serialization can a derived class use default serialization or
vice-versa? I haven't been able to make either of these work.

If anyone can help here, please respond...

Aaron
"Aaron Clamage" <ac******@nospa m.cs.umd.edu> wrote in message
news:#T******** ******@TK2MSFTN GP11.phx.gbl...
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# and I can't figure out the
correct way to do it. It seems that either I can use default serialization or implement ISerializable. Is there any way to do both (e.g. extend the
default serialization). In other words, I want to be able to implement my
custom serialization code but call the default serialization code as well.
In java, I can do this:

private void writeObject(Obj ectOutputStream out) throws IOException {
out.defaultWrit eObject();
//implement my custom code
}

It seems there is no .NET equivalent. In particular I have a class that has a GraphicsPath member. This class implements ISerializable so that it can
correctly serialize the path. But, for the other members including
references to other objects, I would like to use the default serialization. Is this possible? Moreover this class derives from a serializable class
that does not implement ISerializable. Does the derived class have to
serialize all of the inherited members as well, if it chooses to do custom
serialization.

Thanks so much,
Aaron

Nov 15 '05 #2
Aaron,
If you don't have them the following articles covers every thing you wanted
to know about serialization but were afraid to ask:

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

One of the articles discusses how to leverage the FormatterServic es class
with your own code. (read mix & match ISerializable classes with "default
serialization" classes) FormatterServic es is the library that the "default
serialization" code uses to serialization a class that does not implement
ISerializable.

Hope this helps
Jay

"Aaron Clamage" <ac******@nospa m.cs.umd.edu> wrote in message
news:eN******** ********@TK2MSF TNGP09.phx.gbl. ..
To add to/refine this question a bit, is it possible to mix and match custom and default serialization along an inheritance hierarchy. If a base class
uses custom serialization can a derived class use default serialization or
vice-versa? I haven't been able to make either of these work.

If anyone can help here, please respond...

Aaron
"Aaron Clamage" <ac******@nospa m.cs.umd.edu> wrote in message
news:#T******** ******@TK2MSFTN GP11.phx.gbl...
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# and I can't figure out the correct way to do it. It seems that either I can use default

serialization
or implement ISerializable. Is there any way to do both (e.g. extend the default serialization). In other words, I want to be able to implement my custom serialization code but call the default serialization code as well. In java, I can do this:

private void writeObject(Obj ectOutputStream out) throws IOException {
out.defaultWrit eObject();
//implement my custom code
}

It seems there is no .NET equivalent. In particular I have a class that

has
a GraphicsPath member. This class implements ISerializable so that it can correctly serialize the path. But, for the other members including
references to other objects, I would like to use the default

serialization.
Is this possible? Moreover this class derives from a serializable class
that does not implement ISerializable. Does the derived class have to
serialize all of the inherited members as well, if it chooses to do custom serialization.

Thanks so much,
Aaron


Nov 15 '05 #3

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Aaron,
If you don't have them the following articles covers every thing you wanted to know about serialization but were afraid to ask:

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/


They're good articles and I'm grateful to Mr. Richter for writing them, but
they don't take the place of a precise specification like Java's

http://java.sun.com/products/jdk/1.2...alTOC.doc.html

AFAIK, .NET has no equivalent.
Nov 15 '05 #4

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

Similar topics

3
2458
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type System.Collections.Comparer has 1 members, number of members deserialized is 0. at System.Runtime.Serialization.Formatters.Binary.ReadObjectInfo.GetMemberTypes(String
1
3427
by: Mark Overstreet | last post by:
Hi, I have several custom collections that inherit from System.Collections.Specialized.NameObjectCollectionBase and I want to serialize and deserialize with the XMLSerializer object. This works great but my problem is that when the deserialization occurs, it uses the default add method to add objects to the collection without adding the keys. My question is this. Is there any way to use the XMLSerializer object to deserialize and...
8
2344
by: Martin Horn | last post by:
Hi, I am trying to add extra functionality to the standard RichText control, but I've fallen at the first hurdle,can someone take a look at the following code and tell me why it fails to return true if the current selection is bold. Thanks, Martin Horn.
5
3830
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where confusion veered it's ugly head :( Learning Python explains on page 324: Class Interface Techniques (21.3.3 in the ebook) the following is an extender method. ''' #################################### '''
5
4185
by: Gerry Vandermaesen | last post by:
Hi, Does anyone have a freely available JavaScript JSON stringifier. So far my search has been in vain, the one offered on http://www.json.org/json.js does not seem to work for me.
4
11410
by: mijalko | last post by:
Hi, I have inherited my class from System.Drawing.Printing.PrintDocument and I wish to serialize this object using XmlSerializer. And I get exception "There was an error reflecting type ...". If I look at innerException it says: "Cannot serialize member 'System.ComponentModel.Component.Site' of type 'System.ComponentModel.ISite'. OK it is problem to serialize all data so I'll implement my Serialization. I implemented ISerializable...
3
3677
by: katis | last post by:
Hi all :) Is it posible in xsd to change only minOccurs value of element in complex type by extending this type? The problem I'm trying to solve is this: I have two complex types - "TextField" and "FileChooser". Here is definition of "TextField" <xsd:complexType name="TextField">
1
11100
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
2
5564
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as I am trying to read from a binary archive using Boost serialization. I am new to this, and it is possible that I have not understood the usage. In the code below, the string "faultblock" seems to be causing the problem. The code crashes in the ia...
0
8810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9316
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9078
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
9026
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...
0
7955
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6638
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
5959
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
4729
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2526
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.