serialization problem

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

    #1

    serialization problem

    Hi

    I have a problem with serialization and deserialization in a client server
    application. I have to send data of the following form:

    [Serializable]
    public struct Record
    {
    public string firstname, lastname, email, position, company, sector,
    country, biography;
    public byte[] image;
    public Record (string firstname, string lastname, string email, string
    position,
    string company, string country, string sector, string biography)
    {
    this.firstname = firstname;
    this.lastname = lastname;
    this.email = email;
    this.position = position;
    this.company = company;
    this.country = country;
    this.sector = sector;
    this.biography = biography;
    this.image = null; // workaround, won't compile w/o assigning image a
    value
    }
    }

    over a network. I serialize this structure using a BinaryFormater and a
    MemoryStream:

    BinaryFormatter bf = new BinaryFormatter ();
    MemoryStream ms = new MemoryStream();
    bf.Serialize(ms ,rec);

    and deserialize using the same tools:


Working...