我最近升级到Vista x64,突然间,我的machine.config appSettings块没有被任何人读取。NET程序集。
在C:\Windows\Microsoft中,在configSections之后和configProtectedData之前。NET\Framework\v2.0.50727\CONFIG\machine.CONFIG,我有:
<appSettings>
<add key="foo" value="blah"/>
</appSettings>
<system.runtime.remoting>
<customErrors mode="Off"/>
</system.runtime.remoting>
foreach(var s in ConfigurationManager.AppSettings.AllKeys)
{
Console.WriteLine(s);
}
AppSettingsReader asr = new AppSettingsReader();
Console.WriteLine(asr.GetValue("foo", typeof(string)));
---
The following error occurred while executing the snippet:
System.InvalidOperationException: The key 'foo' does not exist in the appSettings configuration section.
at System.Configuration.AppSettingsReader.GetValue(String key, Type type)
at MyClass.RunSnippet()
at MyClass.Main()
---