views:

50

answers:

1

I have a C# WPF application that use several library assemblies.

I was wondring if there was a way to change the key 'applicationSettings' in the app.config file and still allowing VisualStudio 2010 to manage the settings in the project tab.

These library assemblies that the default settings in the project tab of VisualStudio. They all work fine and the client is happy with all of this but they want to use the tag instead of in the app.config.

When I just change applicationSettings to CompanyName, VisualStudio just re-adds applicationSettings and then there are two sections, applicationSettings and CompanyName. The app uses the new applicationSettings settings. So this is not a solution.

I've changed one assembly to derive a settings class from ConfigurationSection and I can make it work but I would have to change the code in every assembly.

I wouldn't have to change every assembly if I could just tell VS2010 to use a different key name. Can anyone help?

TIA, T.

A: 

The config file and the project tab data correspond to a built in applicationSettings class that gets serialized to the config file then deserialized when the application loads. You cannot override this serialization.

As you discovered, in order to serialize your own settings, you need to derive a class form ConfigurationSection and give it its own name.

This is the correct way to add and use custom configuration section, no way around it.

Oded