帮助我解决以下问题:
Type 'System.Resources.RuntimeResourceSet' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
示例代码:
[Serializable] public class clsModelClass { private List _obj1 = new List(); private List _obj2 = new List(); public System.Resources.ResourceManager ResourceManager { get; set; } public string Property1 { get; set; } public long Property2 { get; set; } public string Property3 { get; set; } } [Serializable] public class clsTestClass { public static string staticObj1 = "staticObj1"; public static string staticObj2 = "staticObj2"; public static string staticObj3 = "staticObj3"; }
是因为:
public System.Resources.ResourceManager ResourceManager { get; set; }
因为ResourceManager类未序列化。我是否应该像这样使用[nonSerialize]
[nonSerialize] public System.Resources.ResourceManager ResourceManager { get; set; }
提前谢谢你。
是的,您需要标记不可序列化的对象这可能会有帮助:
NonSerializedAttribute
编辑:进一步说明:
IFormatter formatter = new BinaryFormatter();
IFormatter formatter = new SimpleIniFormatter();
FileStream s = new FileStream(fileName, FileMode.Create);
formatter.Serialize(s, line);`
在本例中,NonSerialized意味着BinaryFormatter将忽略任何恰好标记为NonSerialized的内容。用户可以使用上面的例子来玩。创建的文件具有一定的可读性。其中,line是某个标记为可序列化的对象