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 MemoryStream Serialize() {
MemoryStream stream = New MemoryStream();
SoapFormatter sf = New SoapFormatter(null, New
StreamingContext(StreamingContextStates.All));
sf.Serialize(stream, this);
stream.Seek(0, 0);
return stream;
}
public AdonisConfigDisk Deserialize(MemoryStream ms) {
SoapFormatter sf = New SoapFormatter(null, New
StreamingContext(StreamingCOntextStates.All));
return DirectCast(sf.Deserialize(ms), AdonisConfigDisk);
}
Thanks!
Carl
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 MemoryStream Serialize() {
MemoryStream stream = New MemoryStream();
SoapFormatter sf = New SoapFormatter(null, New
StreamingContext(StreamingContextStates.All));
sf.Serialize(stream, this);
stream.Seek(0, 0);
return stream;
}
public AdonisConfigDisk Deserialize(MemoryStream ms) {
SoapFormatter sf = New SoapFormatter(null, New
StreamingContext(StreamingCOntextStates.All));
return DirectCast(sf.Deserialize(ms), AdonisConfigDisk);
}
Thanks!
Carl