You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

尝试将StringDictionary存入My.Settings失败的问题求助

问题:StringDictionary存入My.Settings后无法持久化,Date类型属性正常工作

我尝试将Dictionary(Of String, String)存入My.Settings,发现该设置仅支持System.Collections.Specialized.StringDictionary——尽管两者并非完全一致,但也可以接受。我创建了一个StringDictionary并填充测试数据,尝试保存后却未成功存储。而另一个Date类型的属性CacheUpdateDate则能正常保存,可按需创建或更新。这些属性的作用域均为"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()

保存后的配置文件内容

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

内容的提问来源于stack exchange,提问作者Oak_3260548

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 04:52:27