Can we have multiple app config files?
Can we have multiple app config files?
NET only loads one config file for the whole application. You cannot use multiple configuration files (i.e. one per library project) without coding. Option: You can use the ConfigurationManager Class to load an alternate config file by code.
What is an app config file?
The app. config file is an XML file whose goal it is to contain any variable configuration of your application. It is a central place to put: Connection strings to databases. Connection details to external services.
How can I use app config from another project?
2 Answers
- Use configuration transformation, like SlowCheetah.
- Add whole config file from one project to another “as a link”
- Inject configuration value to your class (instead of reading it from config)
- Read other project’s config file in runtime, by using things like ConfigurationManager.
Do you need the same app config for multiple projects?
If you are one of those who love to separate your code throughout different projects in a solution, you probably will need to share the same App.config for multiple projects.
How to share single config file in multiple projects?
Step 1: Place the App.Config file in a folder parent to both (or all) the projects that needs to use the same Config file. I have put it in a new folder called AppConfig. Step 2: Right click on each project and select the same App.config file but add it as Link.
What are the settings in app.config in project2?
The Settings.settings in Project2 reflect what its app.config has. The Entity Layer in Project2 has classes which are built from the database tables via easyobjects (MyGeneration) that use Enterprise Library. Here is my dilemma. The classes seem to use the external app config that is referenced in the Project1 app.config via Enterprise Library.
How can I use app config as a shared file?
The trick is to have in a central place the app.config file and to add a existing item as a link instead of a link. This hidden feature combined with some file property allow you to have the single instance of AppSetting on every bin folder. The first step, is to select the project where you want to use the shared file. There is some ways to do it.