Deserialize in a different assembly? How to?

C

Carl Mercier

Hi!

I have 2 different applications/assembly. The first one creates an
object and serializes it to a textfile on disk.

The second one has the the exact same class (copied/pasted). It reads
the file that is on disk and attempts to deserialize it and create a new
object.

The process works fine if I serialize/deserialize in the first
application, but it fails when I try to deserialize in the second
application. Here's the exception:

Parse Error, no assembly associated with Xml key
a1:http://schemas.microsoft.com/clr/ns...9.30011, Culture=neutral, PublicKeyToken=null
AdonisConfigDisk

Although it is generally not a good idea to copy/paste code like I did
(I should have 1 dll with the code I need), I am forced to do so for
some reasons I won't go into right now.

Here's my code... Does anyone have an idea of what I'm doing wrong? How
can I strip the assembly information from the serialized object?

Public Function Serialize() As MemoryStream
Dim stream As New MemoryStream
Dim sf As New SoapFormatter(Nothing, New
StreamingContext(StreamingContextStates.All))
sf.Serialize(stream, Me)
stream.Seek(0, 0)
Return stream
End Function
Public Shared Function Deserialize(ByVal ms As MemoryStream) As
AdonisConfigDisk
Dim sf As New SoapFormatter(Nothing, New
StreamingContext(StreamingContextStates.All))
Return DirectCast(sf.Deserialize(ms), AdonisConfigDisk)
End Function

Thanks!

Carl
 
R

Robert Jacobson

Can you use the basic XML Serializer instead of the Soap Serializer? That
produces a clean XML file that doesn't contain any data about the current
assembly, so there shouldn't be any problem in deserializing it to a
different assembly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top