System.Version

A

Alex Clark

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
 
J

Jay B. Harlow [MVP - Outlook]

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 IXmlSerializable.

To be Xml serializable it needs to implements IXmlSerializable 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


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top