Solved

Serialization: How use a specific Version of the internal serialization-algorithm?

Posted on 2006-07-16
1
182 Views
Last Modified: 2010-04-24
Hello,

my problem is the following:

I have an object that looks like this:

[Serialized]
public class CDBPage{
public Int64 NextID;
...
public Byte[] Data;
...
};

In my test case the serialization algorithm generates 648 Bytes to save my structure with some defined data in the "Data"-Field.
The problem is that the serialized data gets stored in a file with specific boundaries of 648 Bytes (only in this example)... So if there are 10 "CDBPage"-objects are saved, they need 6480 Bytes...

There is no way to implement this in another way, because I need to address a single page in the file with: PageOffset = PageIndex * 648; /* Or any other Alignment */

In the same Version of the CLR there is no problem, of course...

But maybe next versions of the CLR will have another internal serialization standard that maybe generates 650 bytes for the same structure... Do you know what i mean? Now my file will be unuseable with the new CLR, because PageOffset != PageIndex * 648!!!!

And to convert the whole file only to use a new CLR-version is possible but I would prefer another way!!

--------------------------------------

MY QUESTION: Is there any possibility to force the CLR to use the serialization of the .NET Framework 3.0, for the next years or at least till I upgrade the databases in the way described above?

It is enough if I can apply this change only to my object "CDBPage".... But if there is a general possebility for all objects in my assembly its also ok...

Thanks for advance!
0
Comment
Question by:LenWinSonSoft
1 Comment
 
LVL 49

Accepted Solution

by:
DanRollins earned 500 total points
ID: 17124907
My view of this is that Microsoft will be unlikely to modify the internal, default serialization in future versions.  Doing so would immeadiately break all apps that used it and that would be one of the critical issue addressed by the people who wrote it.

If that assuance is not enough, then you always have the option of writing your own serialization/deserialization handlers.

Here's a good 3-part article about serialization
   http://msdn.microsoft.com/msdnmag/issues/02/04/net/default.aspx
   http://msdn.microsoft.com/msdnmag/issues/02/07/net/default.aspx
   http://msdn.microsoft.com/msdnmag/issues/02/09/net/default.aspx
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now