I recently switched to Vista x64, and suddenly my machine.config appSettings block is not read by any .NET assemblies.
Right after the configuration sections and before configProtectedData in C: \ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ CONFIG \ machine.config I have:
<appSettings>
<add key="foo" value="blah"/>
</appSettings>
<system.runtime.remoting>
<customErrors mode="Off"/>
</system.runtime.remoting>
You will have to save it by running Notepad ++ as an administrator, because it is blocked otherwise, probably for good reasons. Running the following code in SnippetCompiler or VS.NET 2008:
foreach(var s in ConfigurationManager.AppSettings.AllKeys)
{
Console.WriteLine(s);
}
AppSettingsReader asr = new AppSettingsReader();
Console.WriteLine(asr.GetValue("foo", typeof(string)));
does not issue any keys and is not executed with the following exception:
---
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()
---
, , machine.config , , app.config, , , 2000 XP.