473,388 Members | 1,390 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,388 software developers and data experts.

Persisted serialized objects & assembly version changes

If you serialize an object graph to persist it somewhere (e.g. a database) between application sessions, then you run into trouble if the serialized objects' existing field order or datatypes change, or if the object is moved from one assembly or namespace to another. Even if we're careful about making such changes, we need to serialize object graphs which may contain objects defined by the user, and users are sure to make incompatible changes to their objects

Assuming you change the asembly versions like you're supposed to when such incompatible changes occur, your application should be able to rehydrate the old objects because the old version of the assembly would be used. But how can you clone the object into its newer version to resave it, so it's not stuck forever in the old version? Somehow your code needs to be able to reference both versions of an object at the same time. Even if you can do that, the cloning process is sufficiently fussy that it seems to me you might as well just serialize your objects in your own simplified data format (XML or otherwise) that doesn't care about field count or order, or namespace, or assembly version. Then you can rehydrate the objects with your own code that can deal with datatype changes or missing fields and can use whatever the new version of the object is

Is it even worth trying to serialize objects for persistence then, using the standard binary or SOAP formatters?
Jul 21 '05 #1
1 1508
I stumbled across SerializationBinder.BindToType(), which among other things, allows you to solve the versioning problem.

The .NET 1.1 Framework help for the BindToType method has an example that creates a Version1TypeToVersion2TypeBinder, inheriting from SerializationBinder, that allows you to substitute types during deserialization. By implementing ISerializable in your new version of the type, you use try/catch around the SerializationInfo.GetXXX() calls to deal with fields that are new or have changed datatype.
Jul 21 '05 #2

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

Similar topics

0
by: kfkyle | last post by:
We are currently developing our build process for an ASP.NET application. This application will consist of about 8 assemblies in total. Even though these assemblies will be deployed in a private...
4
by: Bill | last post by:
I have a DataSet that is serialized to a local disk. One of the testers recently experienced a problem where data was saved and the Tablet PC she was testing later went offline. When she restarted...
0
by: marfi95 | last post by:
Basically, I keep the state of some objects serialized in an xml file through the use of a data set. The xml file serialized is persisted onto a shared network drive. However, the file is only...
1
by: Nels P. Olsen | last post by:
If you serialize an object graph to persist it somewhere (e.g. a database) between application sessions, then you run into trouble if the serialized objects' existing field order or datatypes change,...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
2
by: Sky | last post by:
Hello: I'm trying to make sense of snk files, when to use, under what conditions to regenerate new ones,...can someone take a look if these statemes make sense? And then the final questions at the...
1
by: realgeek | last post by:
I can't get my head around the following problem no matter how I try. ..NET 1.1, C#. There's an assembly A that outputs a COM component. It dynamically loads a class from assembly B using...
5
by: SQLMan_25 | last post by:
Hi All, I am trying to create a user defined function that fetches the price of an item. I have written a scalar function that takes itemid and returns its price. Simple version of tables would...
1
by: Coaster | last post by:
orig ref here http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ff29cc370678911d/c0db5b7e3da283b9?lnk=st&q=gac+assembly+new+version&rnum=7#c0db5b7e3da283b9...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...

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.