473,325 Members | 2,805 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,325 software developers and data experts.

Deserialize in a different assembly? How to?

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/nsa...eyToken%3Dnull
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

Nov 22 '05 #1
1 3243
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.
"Carl Mercier" <in**@carl-mercier.nojunkplease.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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/nsa...%3D1.0.1419.30
011%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dn ull 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

Nov 22 '05 #2

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

Similar topics

1
by: Carl Mercier | last post by:
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...
5
by: aladdinm1 | last post by:
Hi All, I have an annoying trouble with binary serialization. I have a windows forms application which works like a server and keeps sending data to its clients. The data is serialized before...
1
by: Alex | last post by:
I am creating an application that allows the user to link a plug-in "utility" class (Watcher) to a class at runtime. There are several Watcher utilities, each with a different style of "watching"...
0
by: Zsolt Domokos | last post by:
I serialised data in an assembly and I want to deserialize in different assembly but I get an exception: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll...
0
by: Fred Heida | last post by:
Hi Al, i have a funny problem.. i you can call it funny.. what i have is 2 assemblies, the first one does nothing other then Application.Run(new MyForm())
2
by: Henrik Skak Pedersen | last post by:
Hello, I have a class which is beeing serialized/deserialized using the BinaryFormatter class. That has been working with no problems until I signed all my assemblies. Now I get a...
0
by: Fruber Malcome | last post by:
I'm getting a very weird exception and hoping someone may be able to help. I have an Office Add-In that lives in a .dll (for email reference ai.dll) ai.dll makes calls into the core part of the...
1
by: Martin Z | last post by:
I'm getting acquainted with the whole XML/XSD thing, and I've run into a wall. I have a tree of objects that I deserialize from XML for configuration reasons. I have generated XSD from the...
2
by: =?Utf-8?B?VGhlTWFkSGF0dGVy?= | last post by:
oop Q: If I serialize an interface array, then later deserialize it, do I need the original assembly to deserialize it??? Eg: // Inside of "globaly assembly" public interface Ianimal {
0
by: connectpalm03-forum | last post by:
I have a class named (MyClassA) in ControlClasses.dll and was able to serialize it to database. Like below SaveTo(MemoryStream stream) { IFormatter formatter = new BinaryFormatter(); ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.