Various developer configurations for C # class library

We are a small team working on an asp.net web project, as well as a service, both projects depend on a common class library.

We would like the class library settings to be different for each developer (and then for production). Confidential information is included in the settings, such as passwords, as well as host names.

How to assign these parameters?

If I am mistaken, the settings for web.config / application are not good enough, since they do not work for a common class library.

ps: In addition, some variables should be statically linked, while others (such as connection strings) should be dynamic.

+6
c # visual-studio web-config class-library app-config
source share
1 answer

The web.config files app.config are read from any website / application you are running on. I.E., any application settings files in the class library are not used. for example, any references to ConfigurationManager.ConnectionStrings ConfigurationManager.AppSettings in your class library will use some kind of web.config / app.config defined in the application using the class library, and not any .config that can be installed in the class library itself.

The easiest way to manage different settings for each developer and for production is to save your config in another file, for example.

<appSettings configSource="Web.appSettings.dev.config"/> 

Each developer has their own Web.appSettings.dev.config, which is not in the source control. When you are in production, you simply change to:

 <appSettings configSource="Web.appSettings.live.config"/> 

You just need to make sure that you have some kind of Web.appSettings.template.config template in svn, which is a wizard but does not have any parameters in it and manually controls that new keys or connection strings are added to the template devs and the working file are also added to each file.

+2
source share

All Articles