[英]How do I change and/or move a class that has been serialized?
I've got a class in my project and I want to move and rename that class to somewhere else in the project's namespace. 我的项目中有一个类,我想移动该类并将其重命名为项目名称空间中的其他位置。 I tried simply moving it, but then the program won't deserialize any settings saved under Properties.Settings.Default
for that setting. 我尝试简单地移动它,但是程序不会反序列化该设置保存在Properties.Settings.Default
下的任何设置。 Is there a way I can move it without losing all of the user's settings? 有什么方法可以移动它而不会丢失所有用户设置?
I think the SerializationBinder contains a solution for your problem. 我认为SerializationBinder包含针对您的问题的解决方案。
From the MSDN documentation: 从MSDN文档中:
Some users need to control which class to load, either because the class has moved between assemblies or a different version of the class is required on the server and client. 一些用户需要控制加载哪个类,因为该类已在程序集之间移动,或者在服务器和客户端上需要该类的不同版本。
I'll assume your using Studio, have you tried dragging the class into a Class Diagram and renaming from there? 我假设您使用Studio,是否尝试过将类拖到“类图”中并从那里重命名? I find that Studio refactors accordingly from the Class Diagram. 我发现Studio从类图中进行了相应的重构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.