SerializationException thrown when deserializing: "Unable to findassembly"

X

xareon

hi all ^^

that is my problem: i got an application with 2 forms, each having a
button, save and open respectevely. the one with the save button
serializes an object on a file, the one with open deserializes it. In
thi process, i'm using OpenFileDialog e SaveFileDialog Forms. I am
able to serialize the file correctely, but during the deserialization
i got an exception thrown: "Unable to find assembly..."


here's the serialization code:
Code:
//Crea l'oggetto ResultsToSerialize
MyObj resultsToSerialize;
// istanzio l'oggetto


IFormatter binaryFormatter = new BinaryFormatter();
Stream fileStream = new FileStream
(saveFileDialog1.FileName, FileMode.Create, FileAccess.Write,
FileShare.None);
binaryFormatter.Serialize(fileStream,
resultsToSerialize);


fileStream.Close();


and here the deserialization one:
Code:
MyObj resultsToSerialize;
IFormatter binaryFormatter = new BinaryFormatter();


Stream fileStream = new FileStream
(openFileDialog1.FileName, FileMode.Open, FileAccess.Read,
FileShare.None);
MessageBox.Show("filestream creato");
try
{
resultsToSerialize = (MyObj)
(binaryFormatter.Deserialize(fileStream));
}
catch (SerializationException se)
{
MessageBox.Show("SE: " + se.Message);
}
finally
{
fileStream.Close();
}

I tried to find an answer googling a bit, but there isn't a clear
answer at all. Someone says it's a .NET framework v1.5 issue (but i'm
using the 3.5), somene that the binaryFormatter object inserts an
unique string (??) in each serialized file, and thus it's impossible
to deserialize an object in a class that's not the one that has
serialized it. I've also heard that the "unable to find the assembly"
error when deserializing was due to the fact I was trying to serialize/
deserialize in two different application (but i got two different
forms in the same application).

any ideas? thank you all ;)
 
X

xareon

i got some as someone suggested be, i used the Assembly Binding
Log Viewer (Fuslogvw.exe) to find where my error is. I found out it's
about an assembly association, here's the interesting log part about
the error (i'm just hand-translating it, if i manage to change
language to the viewer i can post the whole log)


REG: the same association has been formerly detected. Error hr =
0x80070002.
ERR: critical error during the pre-download verify (hr = 0x80070002).

As far as I know, the last two rows are the detailed error message of
my runtime SerializationException. I cannot understand what "the same
association has been formerly detected" could mean, since i'm just
deserializing a file, not taking care of assembly associations at all.
 

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