Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. A problem with serializtion

A problem with serializtion

Scheduled Pinned Locked Moved Managed C++/CLI
helpxmlquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Mac
    wrote on last edited by
    #1

    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;
    }

    N 1 Reply Last reply
    0
    • M Michael Mac

      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;
      }

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      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 :-)

      M 1 Reply Last reply
      0
      • N Nish Nishant

        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 :-)

        M Offline
        M Offline
        Michael Mac
        wrote on last edited by
        #3

        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? :((

        R 1 Reply Last reply
        0
        • M Michael Mac

          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? :((

          R Offline
          R Offline
          Rama Krishna Vavilala
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • R Rama Krishna Vavilala

            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

            M Offline
            M Offline
            Michael Mac
            wrote on last edited by
            #5

            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

            J 1 Reply Last reply
            0
            • M Michael Mac

              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

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups