Few days ago I've asked a question about object serialization and the answer was working well, actually it still works. But somehow I've copied the serialize function to an another class but didn't fit here and I have no idea why.
Exception has been thrown by the target of an invocation.
Inner Exception: An invalid argument was supplied.
Client.cs
public class Client
{
private string username;
public string Username
{
get { return username; }
set { username = value; }
}
private TcpClient tclient;
public TcpClient tClient
{
get { return tclient; }
set { tclient = value; }
}
public Client()
{}
public string Serialize(object obj)
{
var serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);
}
public object Deserialize(string json)
{
var serializer = new JavaScriptSerializer();
return serializer.Deserialize<object>(json);
}
}
Any ideas?