I am trying to save Dictionary(Of String, String)
into My.Settings
. It seems, that those settings only support System.Collection.Speciallized.StringDictionary
, which is not exactly the same thing, but would be OK. I create a StringDictionary
, fill it with a test data and try to save it, but it doesn't get saved. While another property CacheUpdateDate
of type Date
is saved fine, created or updated as needed. The scope of the properties is "user".
Dim StrDict As New System.Collections.Specialized.StringDictionary
For Each xmlf As KeyValuePair(Of String, String) In XMLfilesCache
StrDict.Add(xmlf.Key, xmlf.Value)
Next
Console.WriteLine("StrDict contains " & StrDict.Count.ToString & " files.")
My.Settings.XMLcache = StrDict
My.Settings.CacheUpdateDate = Date.Now
My.Settings.Save()
Result:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<userSettings>
<DocServiceMonitor.My.MySettings>
<setting name="CacheUpdateDate" serializeAs="String">
<value>05/15/2023 11:26:44</value>
</setting>
<setting name="XMLcache" serializeAs="Xml">
<value />
</setting>
</DocServiceMonitor.My.MySettings>
</userSettings>
</configuration>