views:

31

answers:

1
  1. I have an asp.net 4.0 web application.
  2. I need extensive configuration data for this web application, that is strongly typed and the structure of this configuration data is going to be fairly complex (cannot do with key-value pairs). In the past I remember having done this in .Net 2.0 but cannot figure out how I will do it in .Net 4.0. The class and config mapping is like shown below (really simplified for the purpose of illustration only):

    class SettingsClass
    {
    int count;
    string name;
    decimal amount;
    }

    <SettingsClass>
    <count>2<count>
    <name>Moiz</name>
    <decimal>10.66</decimal>
    </SettingsClass>

    1. I need this configuration in a separate file (other than the web.config).
    2. I don't think I would have to write explicit serialization/deserialization code.

Does .Net 4.0 configuration classes provide this kind of built in facility?

Would I need to use Enterprise Library 5.0 to get this done?

+1  A: 

You can introduce strongly typed sections in configuration files with custom configuration handlers.

If you need these configurations in a separate file you can use OpenMappedExeConfiguration to load additional configuration files.

You can use both practices in .NET 2.0 and 4.0.

Dirk