As consequence of my previous question ( XML serialization of interfaces ) I obtained another problem...
I have an application that export data from a database. The export procedure is implemented by different concrete classes that implement a common interface used for invocation.
The concrete implementations are loaded as plug-ins (DLLs) so I don't reference them in my code directly.
I need to serialize instances of these concrete classes as byte arrays into my database, but now when I try to deserialize them from a byte array I obtain a SerializationException: Unable to find assembly …
I suppose it appens because I load at runtime the dll with the concrete implementation of my interface...
How can I solve it?
NOTE I'm using this code to deserialize objects:
public static object DeSerialize(byte[] arrayToDeSerialize)
{
object serializedObject;
using (MemoryStream stream = new MemoryStream(arrayToDeSerialize))
{
//Creating binary formatter to De-Serialize string.
BinaryFormatter formatter = new BinaryFormatter();
//De-Serializing.
serializedObject = formatter.Deserialize(stream);
}
return serializedObject;
}