C # do we have some .config files for the project?

If we can have several .config files, we can share one configuration file with other projects and put the private configuration in another. Will Visual Studio 2008 get confused?

+3
source share
6 answers

Visual Studio 2010 supports multiple .config files. This is one of the features of the new web application packaging and deployment system. We can create separate web.config files for each configuration that we have for the application. But in 2008, support for multiple configuration files is not supported, you can get around this by adding two configuration files and renaming them during build

Example:

private.config public.config

pre-msbuild

, web.config app.config

, ...

s

+2

, <appSettings> node, file=, "" , - , - .

<appSettings file="common.appsettings.config">
   <add key="private1" value="value1" />
</appSettings>

common.appsettings.config, , , .

"private" , .

+8

- , .

0

. . , , web.config, web.config . , web.config , , . , , , .

0

.config, .

- , XML, . - , . .config .config .

- Visual Studio, .

0

Each configuration section can be placed in an external file and referenced to the main app.config / web.config file through the configSource attribute. However, you will have to write custom section handlers for each custom section / external configuration file that you want to write, which can be a bit tedious. In addition, the appSettings section can be displayed and specified through the same mechanism.

0
source

Source: https://habr.com/ru/post/1743572/


All Articles