アプリケーション用のカスタム .NET アドインがあり、アドインの構成ファイル用の configSections を作成しようとしています。問題は、OpenMapperExeConfiguration/OpenExeConfiguration を使用して構成をロードする場合、そのセクションを読むことができないことです。
ここに私の設定ファイル(MyTest.dll.config)があります
<configuration>
<configSections>
<section name="test" type="MyTest, Test.ConfigRead"/>
</configSections>
<test>
..Stuff here
</test>
<appSettings>
<add key="uri" value="www.cnn.com"/>
</appSettings>
</configuration>
これは、テスト configSection にアクセスするための私のコード サンプルです。
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = Assembly.GetExecutingAssembly().Location + "config";
Configuration applicationConfig = ConfigurationManager.OpenMappedExeConfiguration(fileMap,ConfigurationUserLevel.None);
//Using OpenExeConfiguration doesnt help either.
//Configuration applicationConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
//Accessing test section
applicationConfig.GetSection("test");
//Accessing AppSettings works fine.
AppSettingsSection appSettings = (AppSettingsSection)applicationConfig.GetSection("appSettings");
appSettings.Settings["uri"].Value;
示されているように、appsettings の値は問題なく読み取ることができます。メイン アプリケーションの構成ファイル以外の構成に configSections を含めることは可能ですか?