我正在创建一个非常基本的聊天应用程序 我用tcp连接建立聊天.我经常通过网络流发送序列化对象,因为以这种方式编程更简单.无论如何,如果我有一个class person{ public string name{get;set;} }那么它将是eassy序列化该类.当我包括一个public ImageSource Img {get;set;}我不能再序列化那个班级的人.
我序列化的方式是:
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
Run Code Online (Sandbox Code Playgroud)