开发者

Changing section name in app.config - causes ConfigurationException

开发者 https://www.devze.com 2023-03-18 08:01 出处:网络
I have a WinForms application that I have changed the name of.I\'ve changed the name everywhere I can find it, and can find no traces of the old name (except as below) and everything works fine; the o

I have a WinForms application that I have changed the name of. I've changed the name everywhere I can find it, and can find no traces of the old name (except as below) and everything works fine; the one exception is in app.config, where if I change OLDNAME to NEWNAME any attempt to read any of the configuration settings throws a ConfigurationExceptioon of "Configuration system not ready", if I recall correctly.

Can anyone suggest how I can change the OLDNAME below to something else, such as my new name, without upsetting the config system?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="OLDNAME.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission开发者_Go百科="false" />
        </sectionGroup>
    </configSections>
    <userSettings>
        <OLDNAME.Properties.Settings>
            <setting name="MainWindowPosition" serializeAs="String">
                <value>0, 0, 0, 0</value>
            </setting>
            <setting name="UseShortDeviceNames" serializeAs="String">
                <value>False</value>
            </setting>
        </OLDNAME.Properties.Settings>
    </userSettings>
</configuration>


The link http://www.codeproject.com/Articles/10981/Understanding-Section-Handlers-App-config-File will explain more using Section Handlers for config. You must change alsow the section name, you section name is linked to the projects where is build and you have two posibility: - rename the project (output) and in app.config - create a new custom group and use the settings

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号