System.Version

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Clark

    #1

    System.Version

    Hi All,

    I've searched the documentation and Google for an answer to this but to no
    avail.

    It seems that System.Version does not serialize to XML. I checked the
    documentation and this type is flagged as being Serializable, it has a
    default parameterless constructor, and I'm pretty sure it can be binarily
    serialized without a problem.


    On my example class I have a field as follows:

    Public MyVersion As System.Version

    I initialise this to a new System.Version( 5,5,5,5) before serializing.
    After serializing it to an XML file using the XMLSerializer class all I get
    in my XML doc is "<MyVersion />" - this seems to imply that none of the
    fields in the System.Version class can be serialized into XML?

    Can anyone confirm this?

    Thanks,
    Alex Clark


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: System.Version

    Alex,
    I would not expect System.Version to be Xml serializable as it doesn't have
    any read/write public properties. It only has read only public properties.

    Nor does it implement IXmlSerializabl e.

    To be Xml serializable it needs to implements IXmlSerializabl e or (and?) it
    need to have public read/write properties.

    The Serializable attribute only controls if its Binary serializable...

    --
    Hope this helps
    Jay B. Harlow [MVP - Outlook]
    ..NET Application Architect, Enthusiast, & Evangelist
    T.S. Bradley - http://www.tsbradley.net


    "Alex Clark" <honeycomb@news groups.nospamwr ote in message
    news:OGmfgvYsGH A.4608@TK2MSFTN GP04.phx.gbl...
    | Hi All,
    |
    | I've searched the documentation and Google for an answer to this but to no
    | avail.
    |
    | It seems that System.Version does not serialize to XML. I checked the
    | documentation and this type is flagged as being Serializable, it has a
    | default parameterless constructor, and I'm pretty sure it can be binarily
    | serialized without a problem.
    |
    |
    | On my example class I have a field as follows:
    |
    | Public MyVersion As System.Version
    |
    | I initialise this to a new System.Version( 5,5,5,5) before serializing.
    | After serializing it to an XML file using the XMLSerializer class all I
    get
    | in my XML doc is "<MyVersion />" - this seems to imply that none of the
    | fields in the System.Version class can be serialized into XML?
    |
    | Can anyone confirm this?
    |
    | Thanks,
    | Alex Clark
    |
    |


    Comment

    Working...