views:

358

answers:

1

app.config configuration sections are nice, but I often need multiple configuration sets, but with small difference. what I want is:

  1. Have one section with default configuration (this one is created with the designer, and thus has the auto-generated strongly-typed accessors in the Settings class
  2. Another section with only the "new" items, and all other items get their values from the original section.

(note - it is also would be nice to place that "other section" in a separate file, but this is a different issue.)

Edit: the application is plain executable (or a service) - it is not a web service. Also, I know there is a "machine.config" to inherit from, but its too global: its for all apps together

+1  A: 

I think you'd have to use a custom handler to manage this.

The second part is easy as you can use an configSource Attribute in the original config file to point to a file that contains the xml source.

<system.serviceModel>
    <diagnostics>
      <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
        logMessagesAtTransportLevel="true" />
    </diagnostics>
    <bindings configSource="web.shared.bindings.config" ></bindings>
    <client configSource="web.shared.client.config" ></client>    
</system.serviceModel>

Here is how we link parts of the Service.ServiceModel XML into our Web Config so we can keep them seperate and easily edited.

Brody