首页 > 代码库 > 当引用了Properties.Settings后,如果执行的时候,出现"配置系统无法初始化" 或者 某某节点不正确
当引用了Properties.Settings后,如果执行的时候,出现"配置系统无法初始化" 或者 某某节点不正确
自定义了一个 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>
<PowerConfig.PowerSettings>
<setting name="SharedIp" serializeAs="String">
<value>1.1.1.1</value>
</setting>
</PowerConfig.PowerSettings>
</applicationSettings>
但是执行的时候,却提示配置系统无法初始化,猜测是该配置项有问题,但是不子回到什么原因导致的
搜索了下,才发现,在
<configSections>
<sectionGroup
理也要注册一下,否则,PowerConfig.PowerSettings 找不到<sectionGroup
<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>
<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也能找到的,拷贝过来即可
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。