473,850 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ 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 1785
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.co m

"Rohith" <Ro****@discuss ions.microsoft. com> wrote in message
news:C0******** *************** ***********@mic rosoft.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.co m

"Rohith" <Ro****@discuss ions.microsoft. com> wrote in message
news:C0******** *************** ***********@mic rosoft.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
3529
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 read the session data back from the SQL server using DataSet. Then call "Deserialize" to reveal the session class. I got the following error: "BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 623915045.807743536." ...
2
2625
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: /usr/local/lib/libreadline.4.dylib (compatibility version of user: 4.2.0 greater than library's version: 4.0.0) Trace/BPT trap Has anyone else run into this problem, or know of a solution?
1
1553
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: ========================================================= XmlReader reader = new XmlTextReader("test.xml"); XmlValidatingReader vr = new XmlValidatingReader(reader);
4
3159
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" xmlns:someobj=http://www.abcinc.com/objectdefinition> ...... </SomeObject>
3
9801
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 (when I check the database the field that holds the binary data seems populated), but when I want to deserialize this same byte array the application fails and gives me the following error: Binary stream does not contain a valid BinaryHeader, 0...
3
2073
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
1037
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 serializing in asp.net 1.1 and deserializing in asp.net 1.0. But that isn't the case here - I am just doing a post back. I am doing doing something like the following where Position is the object I
2
1305
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 / desererialized??? Thanks! Clark
3
5003
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 implementations cannot be serialized, I had to take matters into my own hands by implementing a wrapper over the Hashtable which implemted IXmlSerializable. I called it XmlHashtable. It has, among other convenience methods, a method
1
1420
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 error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type System.Data.SqlClient.SqlError has 8 members, number of members deserialized is 7. After reviewing SqlError, framework v1.1 contains the following...
0
9741
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11011
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10666
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10351
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7899
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4546
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 we have to send another system
2
4140
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.