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://img2024.cnblogs.com/blog/35695/202403/35695-20240328092537879-1189167464.jpg)