我正在创建一个非常基础的聊天应用程序。我使用tcp连接建立聊天。我经常通过网络流发送序列化的对象,因为这样更容易编程。无论如何,如果我有一个 class person{ public string name{get;set;} }
,那么序列化该类将非常简单。当我包含一个 public ImageSource Img {get;set;}
时,我就无法再序列化那个person类了。
我的序列化方法如下:
Person p = new Person();
p.name = \\some name
p.Img = \\ some image
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
x.Serialize(connection.stream, p);//here is when the problem comes. I am not able to serialize it if I include an Img