I have a strange exception imo when I try to deserialize a memorystream to
an object using the following code:
public static object Clone(object sheep)
{
if (master == null)
{
throw new ArgumentNullException("sheep");
}
using (MemoryStream stream = new MemoryStream(4096))
{
object dolly = null;
BinaryFormatter formatter = new BinaryFormatter(null, new
StreamingContext(StreamingContextStates.Clone));
formatter.Serialize(stream, sheep);
stream.Seek(0, SeekOrigin.Begin);
dolly = formatter.Deserialize(stream);
return dolly;
}
}
The Exception is thrown by the formatter.Deserialize() method call: "cannot
find assembly x.dll...". For some reason the Deserialize() is trying to look
presumably in the GAC for the x.dll assembly. The object 'sheep' I am trying
to clone is in the same assembly as the utility class with the Clone()
method.
Anyone has experience this before? I am using .NET Framework v1.1.4322...
Gabriel Lozano-Morán