I am using a C# project in .NET and am running into a problem with
deserialization. Previously I have serialized and deserialized these
objects without any problems. However I recently moved some classes
from one assembly to another. This is causing the serialization routine
to be unable to resolve the types saved with the old version of the
code. The error I get is:
Type not resolved for member Foo.Bar.Class1, OldAssembly,
Version=1.0.0.1, Culture=neutral, PublicKeyToken=abcdef123456
The difference is I've moved the class from OldAssembly to NewAssembly.
I have seen an example of someone modifying type and assembly
information at serialization time in an old post, like so:
/// <summary>
/// Method to Serialize object
/// </summary>
/// <param name="info"></param>
/// <param name="context"></param>
[SecurityPermission(SecurityAction.Demand,
SerializationFormatter=true)]
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
info.FullTypeName = "Framework.Server.Configuration";
info.AssemblyName = "Framework.Server.BusinessContext";
[...]
}
However this method still required the user to serialize the full
assembly name, which is my case is now different.
I am sure someone has run into this problem before. Does anyone have a
solution for this? I am wondering if I need to do something with type
converters, or change how I save things with the old code so that the
new code can resolve the type.