I have a class that has been serialized and saved to disk. I am trying to
deserialize it back into the same class which now has an extra private
member. It will not deserialize because its signature has changed so I
added:
Protected Sub New(ByVal info As SerializationIn fo, ByVal context As
StreamingContex t)
End Sub
to my new class so that I can specify custom deserialization however it does
not get called by the deserialization formatter if I don't specify that the
class implements iSerializable. When I do implement iSerializable in my new
class then the class signature no longer matches the old class so an error
gets raised. Seems like I am stuck. Maybe if I had implemented iSerializable
from the beginning in the old class this might have worked but what should I
do now?
Perry 5 1711
Perecli,
One of the following 3 part MSDN Magazine column on Serialization covers
this problem and how to correct it! http://msdn.microsoft.com/msdnmag/issues/02/04/net/ http://msdn.microsoft.com/msdnmag/issues/02/07/net/ http://msdn.microsoft.com/msdnmag/issues/02/09/net/
I hope you read all three, as they are invaluable for implementing
Serialization in .NET!
You are correct in needing to implement ISerializable and give the special
constructor, in addition to implementing ISerializable you need to 'Override
the type when deserializing', which is covered in the 3rd article. It
involves creating a new binder class that changes the type for version 1.0
objects to version 2.0 object.
Hope this helps
Jay
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message
news:e$******** ******@TK2MSFTN GP11.phx.gbl... I have a class that has been serialized and saved to disk. I am trying to deserialize it back into the same class which now has an extra private member. It will not deserialize because its signature has changed so I added:
Protected Sub New(ByVal info As SerializationIn fo, ByVal context As StreamingContex t) End Sub
to my new class so that I can specify custom deserialization however it
does not get called by the deserialization formatter if I don't specify that
the class implements iSerializable. When I do implement iSerializable in my
new class then the class signature no longer matches the old class so an error gets raised. Seems like I am stuck. Maybe if I had implemented
iSerializable from the beginning in the old class this might have worked but what should
I do now?
Perry
Yes, I have read all three articles on your previous recomendation. This is
what got me so far but it is still not working. This is how my
deserialization binder class looks:
Private Class VersionDeserial izationBinder
Inherits SerializationBi nder
Public Overrides Function BindToType(ByVa l assemblyName As
String, ByVal typeName As String) As Type
Return Type.GetType(St ring.Format("{0 }, {1}", typeName,
Reflection.Asse mbly.GetExecuti ngAssembly.Full Name))
End Function
End Class
Still have the same problem mentioned in my initial post.
Perry
"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:eA******** *****@TK2MSFTNG P11.phx.gbl... Perecli, One of the following 3 part MSDN Magazine column on Serialization covers this problem and how to correct it!
http://msdn.microsoft.com/msdnmag/issues/02/04/net/ http://msdn.microsoft.com/msdnmag/issues/02/07/net/ http://msdn.microsoft.com/msdnmag/issues/02/09/net/
I hope you read all three, as they are invaluable for implementing Serialization in .NET!
You are correct in needing to implement ISerializable and give the special constructor, in addition to implementing ISerializable you need to
'Override the type when deserializing', which is covered in the 3rd article. It involves creating a new binder class that changes the type for version 1.0 objects to version 2.0 object.
Hope this helps Jay
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message news:e$******** ******@TK2MSFTN GP11.phx.gbl... I have a class that has been serialized and saved to disk. I am trying
to deserialize it back into the same class which now has an extra private member. It will not deserialize because its signature has changed so I added:
Protected Sub New(ByVal info As SerializationIn fo, ByVal context As StreamingContex t) End Sub
to my new class so that I can specify custom deserialization however it does not get called by the deserialization formatter if I don't specify that the class implements iSerializable. When I do implement iSerializable in my new class then the class signature no longer matches the old class so an
error gets raised. Seems like I am stuck. Maybe if I had implemented iSerializable from the beginning in the old class this might have worked but what
should I do now?
Perry
Perecli,
Not sure what to offer, as your code does not appear at all like the sample
in Figure 3 of article 3.
Are all the types you are deserializing in the same assembly as the
VersionDeserial izationBinder class?
What you may want to do is put a break point in BindToType to see what is
coming in and what is going out, just to be certain that you have
implemented it correctly.
Hint, I suspect the routine is called for types in the System namespace,
such as System.String.
Hope this helps
Jay
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message
news:e5******** ******@tk2msftn gp13.phx.gbl... Yes, I have read all three articles on your previous recomendation. This
is what got me so far but it is still not working. This is how my deserialization binder class looks:
Private Class VersionDeserial izationBinder Inherits SerializationBi nder
Public Overrides Function BindToType(ByVa l assemblyName As String, ByVal typeName As String) As Type Return Type.GetType(St ring.Format("{0 }, {1}", typeName, Reflection.Asse mbly.GetExecuti ngAssembly.Full Name)) End Function End Class
Still have the same problem mentioned in my initial post.
Perry
"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in
message news:eA******** *****@TK2MSFTNG P11.phx.gbl... Perecli, One of the following 3 part MSDN Magazine column on Serialization covers this problem and how to correct it!
http://msdn.microsoft.com/msdnmag/issues/02/04/net/ http://msdn.microsoft.com/msdnmag/issues/02/07/net/ http://msdn.microsoft.com/msdnmag/issues/02/09/net/
I hope you read all three, as they are invaluable for implementing Serialization in .NET!
You are correct in needing to implement ISerializable and give the
special constructor, in addition to implementing ISerializable you need to 'Override the type when deserializing', which is covered in the 3rd article. It involves creating a new binder class that changes the type for version
1.0 objects to version 2.0 object.
Hope this helps Jay
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message news:e$******** ******@TK2MSFTN GP11.phx.gbl... I have a class that has been serialized and saved to disk. I am trying to deserialize it back into the same class which now has an extra private member. It will not deserialize because its signature has changed so I added:
Protected Sub New(ByVal info As SerializationIn fo, ByVal context As StreamingContex t) End Sub
to my new class so that I can specify custom deserialization however
it does not get called by the deserialization formatter if I don't specify
that the class implements iSerializable. When I do implement iSerializable in
my new class then the class signature no longer matches the old class so an error gets raised. Seems like I am stuck. Maybe if I had implemented
iSerializable from the beginning in the old class this might have worked but what should I do now?
Perry
> Not sure what to offer, as your code does not appear at all like the
sample in Figure 3 of article 3.
The sample shows how to deserialize a class with one name into a class with
a differet name. This will not work for my application because all the code
in my app references the class by name.
For example. I serialized a class with the name "MyClass" and saved it to
disk. After this I modified "MyClass" by adding a private member. Now I want
to deserialize the class on disk back into the same class "MyClass", not
another class as is shown in the example.
Are all the types you are deserializing in the same assembly as the VersionDeserial izationBinder class?
Yes
What you may want to do is put a break point in BindToType to see what is coming in and what is going out, just to be certain that you have implemented it correctly.
I have done this and all is OK. The version of the old class is changed to
that of the current assembly.
Hint, I suspect the routine is called for types in the System namespace, such as System.String.
The problem is that when I add "Implements ISerializable" to my new class,
with no other changes as compared to the old class that was serialized. The
deserializer complains that it can't deserialize it to the new class. Keep
in mind that my old class did not implement ISerializable.
Perry
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message news:e5******** ******@tk2msftn gp13.phx.gbl... Yes, I have read all three articles on your previous recomendation. This is what got me so far but it is still not working. This is how my deserialization binder class looks:
Private Class VersionDeserial izationBinder Inherits SerializationBi nder
Public Overrides Function BindToType(ByVa l assemblyName As String, ByVal typeName As String) As Type Return Type.GetType(St ring.Format("{0 }, {1}", typeName, Reflection.Asse mbly.GetExecuti ngAssembly.Full Name)) End Function End Class
Still have the same problem mentioned in my initial post.
Perry
"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message news:eA******** *****@TK2MSFTNG P11.phx.gbl... Perecli, One of the following 3 part MSDN Magazine column on Serialization
covers this problem and how to correct it!
http://msdn.microsoft.com/msdnmag/issues/02/04/net/ http://msdn.microsoft.com/msdnmag/issues/02/07/net/ http://msdn.microsoft.com/msdnmag/issues/02/09/net/
I hope you read all three, as they are invaluable for implementing Serialization in .NET!
You are correct in needing to implement ISerializable and give the special constructor, in addition to implementing ISerializable you need to 'Override the type when deserializing', which is covered in the 3rd article. It involves creating a new binder class that changes the type for version 1.0 objects to version 2.0 object.
Hope this helps Jay
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message news:e$******** ******@TK2MSFTN GP11.phx.gbl... > I have a class that has been serialized and saved to disk. I am
trying to > deserialize it back into the same class which now has an extra
private > member. It will not deserialize because its signature has changed so
I > added: > > Protected Sub New(ByVal info As SerializationIn fo, ByVal context As > StreamingContex t) > End Sub > > to my new class so that I can specify custom deserialization however
it does > not get called by the deserialization formatter if I don't specify that the > class implements iSerializable. When I do implement iSerializable in my new > class then the class signature no longer matches the old class so an error > gets raised. Seems like I am stuck. Maybe if I had implemented iSerializable > from the beginning in the old class this might have worked but what should I > do now? > > Perry > >
Perecli,
Not sure what to offer, I gave you all the tricks I know on the subject.
Asking in either microsoft.publi c.dotnet.framew ork or
microsoft.publi c.dotnet.framew ork.clr might find someone with more knowledge
on Serialization.
Good luck,
Jay
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message
news:e5******** ******@TK2MSFTN GP12.phx.gbl... Not sure what to offer, as your code does not appear at all like the sample in Figure 3 of article 3.
The sample shows how to deserialize a class with one name into a class
with a differet name. This will not work for my application because all the
code in my app references the class by name.
For example. I serialized a class with the name "MyClass" and saved it to disk. After this I modified "MyClass" by adding a private member. Now I
want to deserialize the class on disk back into the same class "MyClass", not another class as is shown in the example.
Are all the types you are deserializing in the same assembly as the VersionDeserial izationBinder class? Yes
What you may want to do is put a break point in BindToType to see what
is coming in and what is going out, just to be certain that you have implemented it correctly.
I have done this and all is OK. The version of the old class is changed to that of the current assembly.
Hint, I suspect the routine is called for types in the System namespace, such as System.String.
The problem is that when I add "Implements ISerializable" to my new class, with no other changes as compared to the old class that was serialized.
The deserializer complains that it can't deserialize it to the new class. Keep in mind that my old class did not implement ISerializable.
Perry
"Perecli Manole" <Pe*****@dslext reme.com> wrote in message news:e5******** ******@tk2msftn gp13.phx.gbl... Yes, I have read all three articles on your previous recomendation.
This is what got me so far but it is still not working. This is how my deserialization binder class looks:
Private Class VersionDeserial izationBinder Inherits SerializationBi nder
Public Overrides Function BindToType(ByVa l assemblyName As String, ByVal typeName As String) As Type Return Type.GetType(St ring.Format("{0 }, {1}",
typeName, Reflection.Asse mbly.GetExecuti ngAssembly.Full Name)) End Function End Class
Still have the same problem mentioned in my initial post.
Perry
"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message news:eA******** *****@TK2MSFTNG P11.phx.gbl... > Perecli, > One of the following 3 part MSDN Magazine column on Serialization covers > this problem and how to correct it! > > http://msdn.microsoft.com/msdnmag/issues/02/04/net/ > http://msdn.microsoft.com/msdnmag/issues/02/07/net/ > http://msdn.microsoft.com/msdnmag/issues/02/09/net/ > > I hope you read all three, as they are invaluable for implementing > Serialization in .NET! > > You are correct in needing to implement ISerializable and give the
special > constructor, in addition to implementing ISerializable you need to 'Override > the type when deserializing', which is covered in the 3rd article.
It > involves creating a new binder class that changes the type for
version 1.0 > objects to version 2.0 object. > > Hope this helps > Jay > > "Perecli Manole" <Pe*****@dslext reme.com> wrote in message > news:e$******** ******@TK2MSFTN GP11.phx.gbl... > > I have a class that has been serialized and saved to disk. I am trying to > > deserialize it back into the same class which now has an extra private > > member. It will not deserialize because its signature has changed
so I > > added: > > > > Protected Sub New(ByVal info As SerializationIn fo, ByVal context
As > > StreamingContex t) > > End Sub > > > > to my new class so that I can specify custom deserialization
however it > does > > not get called by the deserialization formatter if I don't specify that > the > > class implements iSerializable. When I do implement iSerializable
in my > new > > class then the class signature no longer matches the old class so
an error > > gets raised. Seems like I am stuck. Maybe if I had implemented > iSerializable > > from the beginning in the old class this might have worked but
what should > I > > do now? > > > > Perry > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ben |
last post by:
Hi, there.
Recently I was working on a problem where we want to save generic
closures in a data structure (a vector). The closure should work for
any data type and any method with pre-defined signature.
When developing this lib, I figured that the
pointer-to-member-function, although seemingly an attractive solution,
does not work well for us.
|
by: andrewcw |
last post by:
There is an error in XML document (1, 2).
I used XML spy to create the XML and XSD. When I asked to
have the XML validated it said it was OK.
I used the .net SDK to generate the class. I have done
this before but this time I have no idea why I am getting
the error. Any ideas ?? THANKS !
<qcsttatus>
<manual sourcerootfolder="" manualname="">
|
by: Aaron Clamage |
last post by:
Hi,
I'm not sure that if this is the right forum, but any help would be greatly
appreciated.
I am porting some java serialization code to c# and I can't figure out the
correct way to do it. It seems that either I can use default serialization
or implement ISerializable. Is there any way to do both (e.g. extend the
default serialization). In other words, I want to be able to implement my
custom serialization code but call the...
|
by: Uttam |
last post by:
Hello,
We are at a very crucial decision making stage to select between .Net
and Java. Our requirement is to download a class at runtime on the
client computer and execute it using remoting or rmi.
Just to keep my question short I am posting trimmed version of my
code.
//file: Serializable.cs
|
by: Alexander |
last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without
SP1.
An i get this Error:
System.Runtime.Serialization.SerializationException:
Possible Version mismatch. Type System.Collections.Comparer has 1 members,
number of members deserialized is 0.
at
System.Runtime.Serialization.Formatters.Binary.ReadObjectInfo.GetMemberTypes(String
| |
by: mijalko |
last post by:
Hi,
I have inherited my class from System.Drawing.Printing.PrintDocument
and I wish to serialize this object using XmlSerializer. And I get
exception "There was an error reflecting type ...". If I look at
innerException it says: "Cannot serialize member
'System.ComponentModel.Component.Site' of type
'System.ComponentModel.ISite'.
OK it is problem to serialize all data so I'll implement my
Serialization. I implemented ISerializable...
|
by: Nikola Skoric |
last post by:
I ran in Mono a program developed on .NET Framework 2.0 and it ran OK
until I tried to desirialize a object. There the program died abruptly
dumping this:
System.ArgumentOutOfRangeException: Value -8590321990885400808 is
outside the valid range .
Parameter name: ticks
at System.DateTime..ctor (Int64 ticks)
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadPrimitiv
|
by: bharathreddy |
last post by:
Before going to that i want to say few thing on serialization :
Serialization is the process of converting an object into a form that can be readily transported. For example, you can serialize an object and transport it over the Internet using HTTP between a client and a server. On the other end, deserialization reconstructs the object from the stream.
XML serialization serializes only the public fields and property values of an object...
|
by: kikisan |
last post by:
I am developing a windows service which utilizes the following classes:
interface IPersistable;
abstract class PersistableObject : IPersistable;
|
by: mkvenkit.vc |
last post by:
Hello,
I hope this is the right place to post a question on Boost. If not,
please let me know where I can post this message and I will do so.
I am having a strange problem with std::string as I am trying to read
from a binary archive using Boost serialization. I am new to this, and
it is possible that I have not understood the usage. In the code
below, the string "faultblock" seems to be causing the problem. The
code crashes in the ia...
|
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...
| |
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |