简体   繁体   中英

.Net Configuration Editor problem

I have added some settings to my c# application using the configuration editor. There are three configuration items; two of type string and one of type int. All three have Application scope.

When I compile my application the exe.config file contains two subsections under <applicationSettings>. These are <appName.Settings> containing all three configuration items and <appName.Settings1> containing only the string values.

So, instead of having the following structure


<applicationSettings>
   <appName.Settings>
      ...
      ...
      ...
   </appName.Settings>
</applicationSettings>

I have the following structure


<applicationSettings>
    <appName.Settings>
        ...
        ...
        ...
    </appName.Settings>
    <appName.Settings1>
        ...
        ...
    </appName.Settings1>
</applicationSettings>

I have looked at the properties and cannot see anything that looks like it could prompt this behaviour. Can anyone shed any light on why this is happening and tell me how to stop it?

Thanks.

Look near the top of the config file for:

<sectionGroup name="applicationSettings" ...
    <section name="Settings" ...
    <section name="Settings1" ...
</sectionGroup>

Delete the Settings1 entry, then delete the applicationSettings section for Settings1 that you mention above.

<appName.Settings1>
        ...
        ...
</appName.Settings1>

By chance did you change the name of this application or assembly after creating the 2 string settings? When the assembly name changes it creates a new applicationSettings entry, AND leaves the old assembly name settings in the config file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM