我创建一个类库项目。 现在,在默认情况下我有一个app.config文件,这样,我把所有的环境特定的数据在该配置文件。
I am creating one class library project. Now by default I have one App.Config file so that I am putting all environment specific data in that Config file.
现在根据环境(无论是开发/测试/生产),我计划在VS 2010中3的App.config文件,如
Now based on the Environment (whether Dev / Test / Production), I am planning to have three App.Config files in VS 2010 such as
App.Dev.Config App.Test.Config App.Prod.Config
想知道如何将应用程序知道要使用的配置文件。
Wondering how would the application know which config file to use.
任何人都实现了这个场景。任何code样品/文章将是有益的。
Anyone implemented this scenario. Any Code samples / Articles would be helpful.
感谢
推荐答案该应用程序将使用名为YourExcecutable.exe.config配置文件默认情况下是包含在(可执行文件)项目的App.config文件。 请注意,.NET只加载整个应用的一个配置文件。无需编码不能使用多个配置文件(每个库项目,即一个)。
The app will use the config file named YourExcecutable.exe.config which is by default the file App.config included in your (executable) project. Note, that .NET only loads one config file for the whole application. You cannot use multiple configuration files (i.e. one per library project) without coding.
选项:您可以使用postbuild事件和不同的解决方案配置,以复制一个或另一个App.config文件到输出文件夹
Option: You can use postbuild events and different solution configurations to copy one or another App.Config file to the output folder
选项:您可以使用ConfigurationManager的类装载由code备用配置文件
Option: You can use the ConfigurationManager Class to load an alternate config file by code.
更多推荐
多的app.config文件在.NET类库项目
发布评论