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:
and here the deserialization one:
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
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
