I have 2 different projects with 2 different namespace. When i try to serialize object to file with binary serialization everything is fine until i try to deserialize that object in file from second project.
This type of exception is thrown
: 'Unable to find assembly 'Synchro One, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.'
public static void WriteToBinaryFile<T>(string filePath, T objectToWrite, bool append = false)
{
using (Stream stream = File.Open(filePath, append ? FileMode.Append : FileMode.Create))
{
var binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(stream, objectToWrite);
}
}
public static T ReadFromBinaryFile<T>(string filePath)
{
using (Stream stream = File.Open(filePath, FileMode.Open))
{
var binaryFormatter = new BinaryFormatter();
return (T)binaryFormatter.Deserialize(stream);
}
}
These methods are used in both solutions