I have a small test project for checking application version from a server and prompting a user to update. Everything works fine except that I can't save a type of System.Version
to My.Settings
. (I want to save the new version in case a user requests not to be reminded about it again.)
Now, I know I can save Version as a string and convert it back and forth - which I have done to get around this problem - but as System.Version
is listed in the available setting data types, I figure it should work. But instead of saving the version, it merely saves an XML entry "Version" without a value (refer below).
I'm using VB.NET, VS 2013, .NET 4.
Here's some code to look at:
Settings.Designer.vb
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public Property DoNotRemindVersion() As Global.System.Version
Get
Return CType(Me("DoNotRemindVersion"),Global.System.Version)
End Get
Set
Me("DoNotRemindVersion") = value
End Set
End Property
Example assignment
If My.Settings.DoNotRemind Then My.Settings.DoNotRemindVersion = oVersion.NewVersion
(oVersion.NewVersion
is of type System.Version
.)
As saved in user.config
<setting name="DoNotRemindVersion" serializeAs="Xml">
<value>
<Version xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</value>
</setting>
So, what am I doing wrong? I've read a few posts about having to serialize classes to save them to user settings, but this is a simple Version number, which, on the face of things, I would expect to be a supported data type.