我有一个带有用户范围设置的WPF应用程序(test.exe)。我可以看到我的user.config位于C:\ Users \ myname \ AppData \ Local \ test \ test.exe_Url_raornelfbsjbaoakjkwqaipidteatrp5 \ 1.0.0.0。但是如果我查看源代码(没有任何更改),构建并运行它,则不会加载设置,我可以看到在C:\ Users \ myname \ AppData \ Local \ test \ test下生成的另一个user.config文件。 exe_Url_vrsmziieznz0fd3n51hjhct3hgch2ex3 \ 1.0.0.0。
如何从一个位置加载/更新/保存user.config) )?那就是哈希值应保持不变
App.config指定用户范围的设置
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Test.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Test.Properties.Settings>
<setting name="Setting" serializeAs="String">
<value />
</setting>
</Test.Properties.Settings>
// settings class which contains application specific data
public class BookSettings : ApplicationSettingsBase
{
/// <summary>
/// This needs to be public in order for it to work with the .NET
/// runtime
/// </summary>
[UserScopedSetting]
[SettingsSerializeAs(SettingsSerializeAs.Binary)]
[DefaultSettingValue("")]
public Dictionary<string, BookSetting> Settings
{
get
{
return (Dictionary<string, BookSetting>) this["Settings"];
}
set
{
this["Settings"] = value;
}
}
}