473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Deserialization version mismatch

I have a class which is serialized and stored in a file stream. Later I
changed the class with adding some fields to it. Now when I deserialize (I
am deserializing from a later version of my Application) the file framework
throws an exception stating that “Possible Version mismatch. Type [whatever]
has x members, number of members deserialized is y.". Kindly let me know any
work arounds for this problem. If possible send me a sample code that solves
this problem.

Nov 17 '05 #1
2 1768
Rohith,

The only way around this problem is to use custom serialization. This
way, you can pull the values from the serialization info passed to your
constructor.

If you are using .NET 2.0, you can use the OptionalField attribute on a
field to indicate that it is optional to be populated. Of course, once you
do this, you would have to make sure that all new fields added to your type
are optional, or non serializable.

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

"Rohith" <Ro****@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
I have a class which is serialized and stored in a file stream. Later I
changed the class with adding some fields to it. Now when I deserialize
(I
am deserializing from a later version of my Application) the file
framework
throws an exception stating that "Possible Version mismatch. Type
[whatever]
has x members, number of members deserialized is y.". Kindly let me know
any
work arounds for this problem. If possible send me a sample code that
solves
this problem.

Nov 17 '05 #2
Thanks Nicholas...It helps

"Nicholas Paldino [.NET/C# MVP]" wrote:
Rohith,

The only way around this problem is to use custom serialization. This
way, you can pull the values from the serialization info passed to your
constructor.

If you are using .NET 2.0, you can use the OptionalField attribute on a
field to indicate that it is optional to be populated. Of course, once you
do this, you would have to make sure that all new fields added to your type
are optional, or non serializable.

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

"Rohith" <Ro****@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
I have a class which is serialized and stored in a file stream. Later I
changed the class with adding some fields to it. Now when I deserialize
(I
am deserializing from a later version of my Application) the file
framework
throws an exception stating that "Possible Version mismatch. Type
[whatever]
has x members, number of members deserialized is y.". Kindly let me know
any
work arounds for this problem. If possible send me a sample code that
solves
this problem.


Nov 17 '05 #3

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

Similar topics

2
by: WJ | last post by:
I have problem in using "Deserialization" method to work with SQL Session State. The session state data was recorded properly to MS/SQL Server ASPState by a web application. I then attempted to...
2
by: Chris Fonnesbeck | last post by:
I'm trying to run the latest Postgresql on OSX 10.3, but am receiving a version mismatch error when I try and run the database: dyld: psql version mismatch for library:...
1
by: Linus | last post by:
Hi, I'm having problems with some very simple deserialization code and would appreciate it very much if I could get some help here. The following is the code:...
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"...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
0
by: tshad | last post by:
Where does this error come from and what causes it? Possible Version mismatch. Type FtsData.Position has 142 members, number of members deserialized is 102. I did find a post that refers to...
2
by: Clark Sann | last post by:
I've added a property to one of my classes and now, when I deserialize it I am getting a version mismatch. How to you add or subtract properties in classes that are being serialized /...
3
by: John Glover | last post by:
To whoever can help, I've been having a problem with XML deserialization lately. I needed to serialize and deserialze two objects which inherited from Hashtable. Because IDictionary...
1
by: Mythran | last post by:
We have an application on one server and a web service on another server. Our BLL and DAL layers are behind the web service. When a SqlException is thrown, the application receives the following...
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
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.