Change auto implemented properties to normal and deserialization with BinaryFormatter

后端 未结 2 921
不知归路
不知归路 2021-01-13 08:32

I have an object with a property implemented like

public String Bla {get;set;} 

After changing the implementation to something lik

2条回答
  •  Happy的楠姐
    2021-01-13 09:01

    Try implementing ISerializable

        [SecurityCritical]
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
                throw new ArgumentNullException("info");
    
            info.AddValue("name of compiler generated field", _bla);
        }
    

提交回复
热议问题