Serializable class:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Server { [Serializable] class Song { public int songID { get; set; } public string songName { get; set; } public string songArtist { get; set; } public string songAlbum { get; set; } public string songYear { get; set; } public byte[] songPicture { get; set; } public Song(int _songID, string _songName, string _songArtist, string _songAlbum, string _songYear) { songID = _songID; songName = _songName; songArtist = _songArtist; songAlbum = _songAlbum; songYear = _songYear; } } } I transfer from the server to the client
Song thisSong = new Song(0, "HEYHEYHEYHEYHEYHEY", null, null, "nothing"); formatter.Serialize(stream, thisSong); I accept on the client
do { song = formatter.Deserialize(stream) as Song; } while (stream.DataAvailable); When debugging, I found out that stream.DataAvailable = true
I can not understand what caused the problem, this exception pops up on the client
