Multiple App.Config Files in .NET Class library project

后端 未结 3 1461
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 07:20

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.

Now based

3条回答
  •  自闭症患者
    2020-12-05 07:50

    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.

    1. Option: You can use postbuild events and different solution configurations to copy one or another App.Config file to the output folder

    2. Option: You can use the ConfigurationManager Class to load an alternate config file by code.

提交回复
热议问题