我的App.config如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="serviceCollectionSection" type="WSW.Configuration.ServiceCollectionSection, ConsoleApplication1" />
</configSections>
<serviceCollectionSection>
<serviceCollection enableStart="true" waitTimeoutForStartInSeconds="5">
<service name="Service1" source="KnowlagentDataAccessService" logName="application" enableNotification="true"/>
<service name="Service2" source="Service1" logName="application" enableNotification="false"/>
</serviceCollection>
</serviceCollectionSection>
<appSettings>
<add key="KeyName" value="KeyValue"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
</configuration>
在运行时(在Visual Studio的调试模式下),我在记事本中手动打开 vshost.exe.config ,并在Appsettings中更改 KeyName 键的值,并且<自定义部分中的strong> enableNotification 。
然后我刷新部分:
ConfigurationManager.RefreshSection("serviceCollectionSection/serviceCollection");
ConfigurationManager.RefreshSection("appSettings");
我从 appSettings 部分获取 KeyName 键的更新值,但未从自定义部分获取 enableNotification 的更新值。< / p>
任何人,请建议。