473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Deserialization with a removed class

Joe
Hello all!

I'm trying to deserialize an object which has a few members which no longer
exist. Is there anyway using a custom binder to remove the reference to
these objects or just return a null?

Thanks,
Joe
May 31 '06 #1
3 1204
Hello Joe,

There is only 2 ways: either use try/catch or use reflection. I prefer second
one.
In that case you identify the target fields and populate these that actually
exist in the serialization stream

J> Hello all!
J> I'm trying to deserialize an object which has a few members which no
J> longer exist. Is there anyway using a custom binder to remove the
J> reference to these objects or just return a null?
J>
J> Thanks,
J> Joe
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
May 31 '06 #2
Joe,

You have two options here. The first is to implement ISerializable on
the class itself, and handle the case when the members don't exist to
deserialize.

The second is to implement ISerializationSurrogate on a class, and then
have that be the surrogate for the type (you have to set up the formatter to
do this though).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Joe" <jb*******@noemail.noemail> wrote in message
news:OP**************@TK2MSFTNGP05.phx.gbl...
Hello all!

I'm trying to deserialize an object which has a few members which no
longer exist. Is there anyway using a custom binder to remove the
reference to these objects or just return a null?

Thanks,
Joe

May 31 '06 #3
Joe
I'm already using a surrogate. I did find a way within the SetObjectData to
fix my problem.

Thanks,
Joe

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O7****************@TK2MSFTNGP03.phx.gbl...
Joe,

You have two options here. The first is to implement ISerializable on
the class itself, and handle the case when the members don't exist to
deserialize.

The second is to implement ISerializationSurrogate on a class, and then
have that be the surrogate for the type (you have to set up the formatter
to do this though).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Joe" <jb*******@noemail.noemail> wrote in message
news:OP**************@TK2MSFTNGP05.phx.gbl...
Hello all!

I'm trying to deserialize an object which has a few members which no
longer exist. Is there anyway using a custom binder to remove the
reference to these objects or just return a null?

Thanks,
Joe


May 31 '06 #4

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

Similar topics

0
by: Jason | last post by:
I have a class that inherits from CollectionBase. My derived class raises events whenever items are added or removed from the collection. When I try to serialize my class I get errors because of...
2
by: Meta-Meta | last post by:
Hi, I'm trying to deserialize a VC++ .NET class and am stumped by the following problem : In order to create the XmlSerializer you need to pass the type of the object being created. The doc...
1
by: Tom L | last post by:
Simple deserialization help needed please... I have a packet of xml in a string, and need to get that into a reader./stream of some sort so I can properly use deserialize.. here's my...
4
by: Mike Sarbu | last post by:
Hello all, I have an XML file like this: <?xml version="1.0" encoding="utf-8"?> <SomeObject xmlns="http://www.abcinc.com/objectdefinition"...
6
by: Nick Z. | last post by:
I need my program to start as fast as possible. Will deserialization a few settings using binary deserialization affect that? Or should I keep these settings in XML, will that be any better? ...
5
by: Solel Software | last post by:
Hello, I am attempting to serialize an object for storage in a DB field and them deserialize it later on. I have managed to Serialize it using private string SerializeObject(object...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
8
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a...
7
by: Andrew | last post by:
Hi, I am using DataContractJsonSerializer to deserialize JSON string in C# objects but I am having a problem. Suppose I have a class: class Item { public ItemId Id { get; set; }
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
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
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...
0
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...

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.