自定义了一个 PowerConfig命名空间 PowerSettings.Settings
然后一个exe,引用了该dll,在app.cinfig里增加了配置项
<applicationSettings>
<PowerConfig.PowerSettings>
<setting name="SharedIp" serializeAs="String">
<value>1.1.1.1</value>
</setting>
</PowerConfig.PowerSettings>
</applicationSettings>
但是执行的时候,却提示配置系统无法初始化,猜测是该配置项有问题,但是不子回到什么原因导致的
搜索了下,才发现,在
<configSections>
<sectionGroup
理也要注册一下,否则,PowerConfig.PowerSettings 找不到
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="PuppetTool.PutpetSet" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="PuppetTool.TolSet" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="PowerConfig.PowerSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
蓝色部分,为自己增加的,其实也就是个section名字,后面的跟上面的都一样,这个在PowerConfig的app.config也能找到的,拷贝过来即可
当引用了Properties.Settings后,如果执行的时候,出现"配置系统无法初始化" 或者 某某节点不正确