Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving a section of app.config to a separate file

for an easiness of my application I would need to have "runtime" element of app.config in separate file.

Tried something like

<runtime file="runtime.conf" />

and also

<runtime configFile="runtime.conf" />

and in runtime.conf I have:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
            .......
    </assemblyBinding>
</runtime>

But it is ignored ...

Is there a way to find out what is wrong.

Of course when I copy runtime section directly into app.config it works.

I somewhere found that when using configFile="..." included file must lay in a subdirectory. Tried it but it also doesn't work...

Seems including is not working for runtime section.

like image 378
RomanT Avatar asked May 18 '09 11:05

RomanT


People also ask

How do I add a config section in app config?

Open the App. config file and add the configSections, sectionGroup and section to it. We need to specify the name and fully qualified type of all the section and section group.

Can we have multiple config files?

You can have multiple configuration files in your asp.net project. There is no restriction to use the web. config file in the asp.net web application. You can have 1 Web.

Where is the app config file located?

The application configuration file usually lives in the same directory as your application. For web applications, it is named Web. config. For non-web applications, it starts life with the name of App.


1 Answers

You can't use configSource to externalize the <runtime> configuration.

<runtime> is a special case that doesn't read the values in any external file specified in configSource.

Specifying the "configSource" attribute won't cause an error, the source file simply won't be read.

More information here: http://world.episerver.com/Blogs/Magnus-Rahl/Dates/2011/6/Todays-gotcha-configSource-on-the-runtime-section-element/

  • Including speculation that this is related to the "IgnoreSection" type information.
like image 145
jeffreypriebe Avatar answered Oct 22 '22 01:10

jeffreypriebe