472,811 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

SOAP serialization exception

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.SerializationExcepti on' 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


Nov 16 '05 #1
6 4081
Hi Tim,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when your class structure changes, your
app cannot deserialize an old version of Xml file that was serialized. If
there is any misunderstanding, please feel free to let me know.

Generally, I think this exception was thrown because you have changed the
members for your class. However, I think changing the structure back to
when the XML was created should make deserialization work. Could you please
try to check your code to see if you have forgotten any other things in the
class?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #2

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:vX**************@cpmsftngxa10.phx.gbl...
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when your class structure changes,
your
app cannot deserialize an old version of Xml file that was serialized. If
there is any misunderstanding, please feel free to let me know.


That's not quite right. The scenario is:

An object of classv1 is serialized to an xml file using the SOAP serializer
A new version of the app has a modified version of classv1, lets call it
classv2 (the actually class name is the same)
I now want to deserialize the xml file to an object of classv2.

Obviously there are different members in classv2. However, by implementing
ISerializable you can handle this situation by deserializing as far as you
can (in the overridden constructor) and catching the SerializationException.
You can then assign default values to the unserialized members.

This technique has worked well for several versions of the class. However,
it is now failing with the following exception *before* my constructor
starts to
run. Visual Studio reports:

A first chance exception of type
'System.Runtime.Serialization.SerializationExcepti on' 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 problem here is that I can't deserialize *any* of the pre-existing XML
file.

Since we don't have the source for the SOAP serializer, a good starting
point would be what this "Top Object" exception actually means?

Thanks,

Tim
Nov 16 '05 #3
Hi Tim,

Thanks for clarify the issue. To troubleshoot this issue, we have to step
into the ISerializabe.GetObjectData method to see which line throws the
SerializationException. When you find the line of code, please check if it
is in the Try block. If the code is in Try block, it has to be catched and
continue deserializing.

If that still doesn't help, could you please send me a repro by email? It
is better if you also attach a former version that works fine. Remove
'online' from the no spam alias is my real email.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #4
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:0w**************@cpmsftngxa10.phx.gbl...
Hi Tim,

Thanks for clarify the issue. To troubleshoot this issue, we have to step
into the ISerializabe.GetObjectData method to see which line throws the
SerializationException. When you find the line of code, please check if it
is in the Try block. If the code is in Try block, it has to be catched and
continue deserializing.


I'm a bit confused by this. GetObjectData is called for serialization, not
deserialization. I'm getting the exception when deserializing.

The equivalent code would be the constructor. However, as I mentioned, the
exception is thrown before the code in the constructor runs, hence my
problem.

Tim
Nov 16 '05 #5
Hi Tim,

You're right. GetObjectData is used for serialization.

It's hard to troubleshoot this issue without a repro. Could you please
provide me with a repro package with the mListColor member and still throws
an exception? Remove 'online' from the no spam alias is my real email
address.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #6
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:Ty**************@cpmsftngxa10.phx.gbl...
Hi Tim,

You're right. GetObjectData is used for serialization.

It's hard to troubleshoot this issue without a repro. Could you please
provide me with a repro package with the mListColor member and still
throws
an exception? Remove 'online' from the no spam alias is my real email
address.


I've now found a workaround. The problem occurred because of changes I made
to the type of one of the fields being serialized. I amended this type to
implement ISerializable. I then got the "top object" exception. I've
reverted this type not to implement ISerializable and the deserialization of
an old version now works as expected.

Thanks,

Tim

Nov 16 '05 #7

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

Similar topics

2
by: Bob Rundle | last post by:
I can't seem to control the soap formatting. SoapTypeAttribute() doesn't seem to have any affect on the SOAP serialization. Here is my sampe code. What am I doing wrong? Regards, Bob Rundle ...
0
by: craig | last post by:
Hi, I'm new to all this and having tremendous difficulty trying to deserialize the following: <soap-env:Envelope...
0
by: Cleo | last post by:
Hi, I am trying to call a WebService Method written in Weblogic from VB.NET and I am getting the following error. I am using SOAP Caal s from VB.NET. Please find the wsdl file and my code. ...
1
by: Tim Anderson | last post by:
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...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
0
by: Matt Wood | last post by:
Hi, I have written a Web Service for a customer which expects a SOAP message with Document/Literal encoding, and uses RoutingStyle=SoapServiceRoutingStyle.RequestElement to route the SOAP body...
3
by: JRey | last post by:
Does .Net generate the classes for Faults when they are specified in the WSDL. I tried defining them and then generating a proxy, and it did not appear to do it. On the Java side it did generate...
0
by: GAURAV KRISHNA | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element using...
0
by: Nol | last post by:
Hi all, My webservice throws an exception, which is translated into a soap Fault in the soap message body. See below for the actual message format as it is send by the server. On the (dotNet)...
4
by: Nol de Wit | last post by:
(this is a re-post of a message I've posted last friday, but now from my MSDN subscription account, hoping MSDN support will pick this up...) Hi all, My webservice throws an exception, which...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.