Object Deseralization issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arno

    #1

    Object Deseralization issue

    I have a class marked as [Serializable]. This class contains private members
    that I don't need to serialize, as such I've tagged their declaration as
    [NonSerialized]. Most of these members are initialized in the constructor of
    my class.

    The serialization and deserialization works fine BUT, when deserializing
    (hence re-creating objects graph) I'm loosing these non-serialized members
    initialization.
    I thought that the object constructor would be executed anyhow, which
    doesn't seem to be the case.

    Here is my code snippet:

    [Serializable]
    public class Satellite
    {
    private String ip; // This member will be serialized
    private int port; // This member will be serialized
    [NonSerialized] private String _status; // Volatile info, no need to be
    serialized
    [NonSerialized] private int _statusCode; // Volatile info, no need to be
    serialized

    public void Satellite()
    {
    this._status = "Unknown";
    this._statusCod e = 0;
    }
    }

    Any idea, comment or documentation pointer is welcomed.
    Thanks in advance.
    Arno
Working...