Solved

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

Posted on 2006-07-16
1
183 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Setting font in GroupBox 10 136
Drive driver 2 98
L prefix in C++ 8 103
VB.NET Project - how to generate list of subs and functions? 2 66
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

13 Experts available now in Live!

Get 1:1 Help Now