A problem with serializtion
-
I want to serialize using xml a class which contains a IPEndPoint field. I can't get it to work. Does anybody know what to do? But I don't want to use other formatter. Help!!! Please. :((
public class __gc Message
{
public:
__property Byte get_ByteMessage ( )[] { return m_byteMessage; }
__property void set_ByteMessage ( Byte byteMessage[] ) { m_byteMessage = byteMessage; }
__property IPEndPoint* get_Sender ( ) { return m_ipeEndPoint; }
private:
Byte m_byteMessage[];
IPEndPoint* m_ipeEndPoint;
} -
I want to serialize using xml a class which contains a IPEndPoint field. I can't get it to work. Does anybody know what to do? But I don't want to use other formatter. Help!!! Please. :((
public class __gc Message
{
public:
__property Byte get_ByteMessage ( )[] { return m_byteMessage; }
__property void set_ByteMessage ( Byte byteMessage[] ) { m_byteMessage = byteMessage; }
__property IPEndPoint* get_Sender ( ) { return m_ipeEndPoint; }
private:
Byte m_byteMessage[];
IPEndPoint* m_ipeEndPoint;
}Is IPEndPoint a serializable class? If not it won;t get serialized. Not automatically. Not sure of this, but if you can derive another class from IPEndPoint, and then add the serialization stuff, it just might work. Not very sure about it though, as I already said :-)
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)
-
Is IPEndPoint a serializable class? If not it won;t get serialized. Not automatically. Not sure of this, but if you can derive another class from IPEndPoint, and then add the serialization stuff, it just might work. Not very sure about it though, as I already said :-)
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)
IPEndPoint is a serializable class. In addition, I can't even serialize IPEndPoint itself using xml of course.
m_xmlsSerializer = new XmlSerializer( __typeof ( IPEndPoint) );
// an error with message "There was an error reflecting 'System.Net.IPEndPoint'.Any other ideas? :((
-
IPEndPoint is a serializable class. In addition, I can't even serialize IPEndPoint itself using xml of course.
m_xmlsSerializer = new XmlSerializer( __typeof ( IPEndPoint) );
// an error with message "There was an error reflecting 'System.Net.IPEndPoint'.Any other ideas? :((
Michael Mac wrote: I can't even serialize IPEndPoint itself using xml of course. Does it have a public constructor? The exception normally gives the detail reason of what is missing from the class
-
Michael Mac wrote: I can't even serialize IPEndPoint itself using xml of course. Does it have a public constructor? The exception normally gives the detail reason of what is missing from the class
The code shown below
XmlSerializer* xml = new XmlSerializer ( __typeof( IPEndPoint ) );
returns an exception with the message: "There was an error reflecting 'System.Net.IPEndPoint'". So I think it's impossible to serialize IPEndPoint class using XML. The alternatives are BinaryFormatter and SoapFormatter. 43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c
-
The code shown below
XmlSerializer* xml = new XmlSerializer ( __typeof( IPEndPoint ) );
returns an exception with the message: "There was an error reflecting 'System.Net.IPEndPoint'". So I think it's impossible to serialize IPEndPoint class using XML. The alternatives are BinaryFormatter and SoapFormatter. 43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c
Correct; unfortunately MS didn't document this topic very well. The XmlSerializer doesn't use any of the other serialization stuff, no Serializable attribute nor ISerializable; I think its a shame myself. The XmlSerializer works by using the reflection.emit classes to construct a class that will place all the public fields/property's in an XML document; when it deserializes it tries to access the nodes in the document as the field/property name to place the value back in. When it does this it creates an instance of the object using the default constructor. It DOES let you control some functionality by using Attributes and the OverrideAttributes class; but I don't like that solution very well. James