I have an app that uses the SOAP serializer to serialize and deserialize a
object of a certain class to a file. The class implements ISerializable.
From time to time it is necessary to add or remove fields from the class.
I've been able to deserialize out-of-date versions by handling serialization
exceptions in Sub New(ByVal info As SerializationInfo, ByVal context As
StreamingContext).
I've now hit a problem. With the latest version, if I try to deserialize an
out-of-date XML file I get an exception *before* my constructor starts to
run. Visual Studio reports:
A first chance exception of type
'System.Runtime.Serialization.SerializationException' occurred in
system.runtime.serialization.formatters.soap.dll
The message is: Top Object cannot be instantiated for element 'mListColor'.
mListColor is a field that no longer exists; however even if I do the
obvious thing and add it back, I still get the same error.
The serialization and deserialization works fine with newly serialized
files; it is just deserializing the old version that is not working.
How can I troubleshoot this?
Thanks for any advice,
Tim
"Matt Tavis [MSFT]" - 30 Sep 2004 18:30 GMT
Does the type mListColor represents still exist as well? If not, then that
could be your problem as well. If that isn't it then please send a more
complete stack trace and a repro if possible.
Thanks.
Matt Tavis
Program Manager
XML Web Services
Microsoft Corporation
--------------------
From: "Tim Anderson" <timjand@hotmail.com>
Subject: SOAP serialization exception
Date: Thu, 26 Aug 2004 15:38:17 +0100
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <OQkNVp3iEHA.396@TK2MSFTNGP12.phx.gbl>
Newsgroups:
microsoft.public.dotnet.framework.webservices,microsoft.public.dotnet.langua
ges.csharp
NNTP-Posting-Host: onlyconn.gotadsl.co.uk 82.133.123.179
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA02.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:268249
microsoft.public.dotnet.framework.webservices:6370
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices
I have an app that uses the SOAP serializer to serialize and deserialize a
object of a certain class to a file. The class implements ISerializable.
From time to time it is necessary to add or remove fields from the class.
I've been able to deserialize out-of-date versions by handling serialization
exceptions in Sub New(ByVal info As SerializationInfo, ByVal context As
StreamingContext).
I've now hit a problem. With the latest version, if I try to deserialize an
out-of-date XML file I get an exception *before* my constructor starts to
run. Visual Studio reports:
A first chance exception of type
'System.Runtime.Serialization.SerializationException' occurred in
system.runtime.serialization.formatters.soap.dll
The message is: Top Object cannot be instantiated for element 'mListColor'.
mListColor is a field that no longer exists; however even if I do the
obvious thing and add it back, I still get the same error.
The serialization and deserialization works fine with newly serialized
files; it is just deserializing the old version that is not working.
How can I troubleshoot this?
Thanks for any advice,
Tim