public void DeSerialize()
{
BinaryFormatter formatter = new BinaryFormatter();
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnResolveAssembly);
formatter.Deserialize(stream);
AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(OnResolveAssembly);
}
private Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
{
Assembly assembly = System.Reflection.Assembly.Load(args.Name);
if (assembly != null)
{
return assembly;
}
return Assembly.GetExecutingAssembly();
}
转载于:https://www.cnblogs.com/chuwachen/p/3911011.html