I have an app.config file that contains the following
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name ="PowershellSnapIns" type ="System.Configuration.DictionarySectionHandler,System"/>
</configSections>
<PowershellSnapIns>
<add key="SnapIn1" value="WebAdministration" />
<add key="SnapIn2" value="Jimmy Hendrix" />
<add key="SnapIn3" value="..." />
</PowershellSnapIns>
</configuration>
I was going to use the ConfigurationSettings class to read it, but that was deprecated. It was pretty easy to use. Now I have to use the ConfigurationManager class, and now I have this code to read it.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
IDictionary SnapInList = (IDictionary) config.GetSection("PowershellSnapIns");
But he continues to fail. I changed the properties of app.config to copy it to the assembly, but it continues to believe that it cannot find the file. An exception says what he is looking for
TestConsole.vshost.exe.config. Now vs2k8sp1 will automatically rename app.config, and if so, what am I doing wrong? Of course, I don't need to rename the app.config file to debug vhost. In the version, I know that it is probably renamed to TestConsole.exe.config. So what's wrong? Is this the wrong code or what?