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(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
//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 3 3156
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******@nospam.cs.umd.edu> wrote in message
news:#T**************@TK2MSFTNGP11.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(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); //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
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 FormatterServices class
with your own code. (read mix & match ISerializable classes with "default
serialization" classes) FormatterServices 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******@nospam.cs.umd.edu> wrote in message
news:eN****************@TK2MSFTNGP09.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******@nospam.cs.umd.edu> wrote in message news:#T**************@TK2MSFTNGP11.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(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); //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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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.
| |
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...
|
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 -...
|
by: kikisan |
last post by:
I am developing a windows service which utilizes the following classes:
interface IPersistable;
abstract class PersistableObject : IPersistable;
|
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...
|
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,...
|
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...
| |
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: 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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |