Pergunta

Help me to resolve following issues:

Type 'System.Resources.RuntimeResourceSet' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

Sample Code:

[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";
    }

Is it because of :

public System.Resources.ResourceManager ResourceManager { get; set; }

since ResourceManager class is not serialized. Should i use [nonSerialize] like

[nonSerialize]
public System.Resources.ResourceManager ResourceManager { get; set; }

Thanks in advance.

Foi útil?

Solução

yes, you need to mark non-serializable objects this might help:

NonSerializedAttribute

Edit: Further explanation:

IFormatter formatter = new BinaryFormatter();             
IFormatter formatter = new SimpleIniFormatter();
FileStream s = new FileStream(fileName, FileMode.Create);
formatter.Serialize(s, line);`

In this example NonSerialized means that the BinaryFormatter will ignore whatever happens to be marked as nonserialized. User the above example to play around. The created file is sort of readable. Where line is some Object marked as serializable

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top