473,396 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Serialization Headaches

Hi, I really need some expert help... please! Basically, I need to
serialize a data structure object to a file using SOAP and then load and
de-serialize that file in ANOTHER program. When I serialize / deserialize
the object in the SAME application, it works fine but when I simply copy the
identical code to another application and try deserialization from that
second application, I get the error:

An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
system.runtime.serialization.formatters.soap.dll

Additional information: Parse Error, no assembly associated with Xml key
a1:http://schemas.microsoft.com/clr/nsa...Empression%20C
lient%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutra l%2C%20PublicKeyToken%3Dnu
ll General+SerializableData

A sample of the code I've been using to serialize and deserialize objects is
below:

Sub SaveSOAPData (ByVal path as String, ByVal o as Object)

Dim fs as FileStream = New FileStream (path, FileMode.Create)

Dim sf as New SoapFormatter (Nothing, New StreamingContext
(StreamingContextStates.File))

sf.Serialize (fs, O)

fs.close

End Sub

Function LoadSOAPData (ByVal path As String) As Object

Dim fs as FileStream = New FileStream (path, FileMode.Open)

Dim sf as New SoapFormatter (Nothing, New StreamingContext
(StreamingContextStates.File))

LoadSOAPData = sf.Deserialize (fs)

fs.close

End Function

I'd appreciate any help that anyone can offer.

Thanks in advance!!!!!
Nov 20 '05 #1
2 2518
Luck,
When you serialize an object to a file, one of the items serialized is the
assembly doing the serialization, when you deserialize the object, the
system checks the current assembly version against the version in the
serialized object. If these versions are different you see the error.

I would recommend you use a single class library that does the actual
serialization & deserialization, ensuring the assembly version is constant.

One of the following articles on serialization discusses how you can change
the version info read from an assembly, which is used more for version 2
program being able to read version 1 versions of the serialized data, not so
program 1 can read program 2 data per se (read, as I would recommend a
single assembly used by both programs).

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/

Hope this helps
Jay

"Luck" <lu********@yahoo.com> wrote in message
news:KQWuc.600670$Pk3.579675@pd7tw1no...
Hi, I really need some expert help... please! Basically, I need to
serialize a data structure object to a file using SOAP and then load and
de-serialize that file in ANOTHER program. When I serialize / deserialize
the object in the SAME application, it works fine but when I simply copy the identical code to another application and try deserialization from that
second application, I get the error:

An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
system.runtime.serialization.formatters.soap.dll

Additional information: Parse Error, no assembly associated with Xml key
a1:http://schemas.microsoft.com/clr/nsa...Empression%20C lient%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutra l%2C%20PublicKeyToken%3Dnu ll General+SerializableData

A sample of the code I've been using to serialize and deserialize objects is below:

Sub SaveSOAPData (ByVal path as String, ByVal o as Object)
Dim fs as FileStream = New FileStream (path, FileMode.Create)
Dim sf as New SoapFormatter (Nothing, New StreamingContext
(StreamingContextStates.File))
sf.Serialize (fs, O)
fs.close
End Sub

Function LoadSOAPData (ByVal path As String) As Object
Dim fs as FileStream = New FileStream (path, FileMode.Open)
Dim sf as New SoapFormatter (Nothing, New StreamingContext
(StreamingContextStates.File))
LoadSOAPData = sf.Deserialize (fs)
fs.close
End Function

I'd appreciate any help that anyone can offer.

Thanks in advance!!!!!

Nov 20 '05 #2
Jay, you're amazing. That's what I was looking for.
Thanks again,
Luck

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
Luck,
When you serialize an object to a file, one of the items serialized is the
assembly doing the serialization, when you deserialize the object, the
system checks the current assembly version against the version in the
serialized object. If these versions are different you see the error.

I would recommend you use a single class library that does the actual
serialization & deserialization, ensuring the assembly version is constant.
One of the following articles on serialization discusses how you can change the version info read from an assembly, which is used more for version 2
program being able to read version 1 versions of the serialized data, not so program 1 can read program 2 data per se (read, as I would recommend a
single assembly used by both programs).

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/

Hope this helps
Jay

"Luck" <lu********@yahoo.com> wrote in message
news:KQWuc.600670$Pk3.579675@pd7tw1no...
Hi, I really need some expert help... please! Basically, I need to
serialize a data structure object to a file using SOAP and then load and
de-serialize that file in ANOTHER program. When I serialize / deserialize the object in the SAME application, it works fine but when I simply copy the
identical code to another application and try deserialization from that
second application, I get the error:

An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
system.runtime.serialization.formatters.soap.dll

Additional information: Parse Error, no assembly associated with Xml key

a1:http://schemas.microsoft.com/clr/nsa...Empression%20C

lient%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutra l%2C%20PublicKeyToken%3Dnu
ll General+SerializableData

A sample of the code I've been using to serialize and deserialize

objects is
below:

Sub SaveSOAPData (ByVal path as String, ByVal o as Object)
Dim fs as FileStream = New FileStream (path, FileMode.Create)
Dim sf as New SoapFormatter (Nothing, New StreamingContext
(StreamingContextStates.File))
sf.Serialize (fs, O)
fs.close
End Sub

Function LoadSOAPData (ByVal path As String) As Object
Dim fs as FileStream = New FileStream (path, FileMode.Open)
Dim sf as New SoapFormatter (Nothing, New StreamingContext
(StreamingContextStates.File))
LoadSOAPData = sf.Deserialize (fs)
fs.close
End Function

I'd appreciate any help that anyone can offer.

Thanks in advance!!!!!


Nov 20 '05 #3

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

Similar topics

37
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...
1
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...
3
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. ...
3
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...
4
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...
5
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:...
0
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...
1
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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
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,...

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.