What happens to app.config in a referenced project

后端 未结 4 1807
盖世英雄少女心
盖世英雄少女心 2021-02-19 07:43

Say I have 2 projects, where project A references project B. Project A is a web application project and project B is a class library.

The class library has an app.confi

相关标签:
4条回答
  • 2021-02-19 07:49

    App.config is configuration, not application - so it's not saved into dll and it can't be displayed by reflector or decompiled.

    You have to configure Project B with settings for Project A (in web.config as it is web app).

    There is no mechanism to automagicaly configure external modules, unless they have coded default fall-back values.

    0 讨论(0)
  • 2021-02-19 07:51

    You can add an app.config to a library project, but it is not used or included in any of the output.

    Configuration is meant to be done in the application - not in the library. So you need to put the configuration in question in the web.config of your web application, not in app.config of a library.

    0 讨论(0)
  • 2021-02-19 07:56

    App.config of your class library B becomes irrelevant. If you want to use data from there you should copy all the stuff to app.config of your parent application (in your case web.config). You will then be able to access contents of it using ConfigurationManager both from projects A and B

    0 讨论(0)
  • 2021-02-19 08:02

    At runtime, your project B will use the settings of your web application project (the host). So you would have to recopy your settings in the web.config file.

    0 讨论(0)
提交回复
热议问题