Solved

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

Posted on 2006-07-16
1
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 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