Is there any way for an App.config file to reference another full config file? (.NET)

て烟熏妆下的殇ゞ 提交于 2019-11-27 07:54:04

I think you just remove the configSource attributes and then include all the content within the <appSettings> and <connectionStrings> elements

I was able to get this to work using configSource

<configSections>
    <section name="Sites"
             type="Wap.Common.Configuration.SiteHandler, Wap.Common" />
</configSections>

<Sites configSource="Sites.Prod.config" />

and then in the external config file it needs to have the ?xml tag

<?xml version="1.0" encoding="utf-8" ?>
<Sites>
...
</Sites>

and then you need to set up the external config file to always copy to the output directory

You should not put the system.net section inside the appSettings.config. The standard practice is one config node in a sub config file. I'm not even sure if it's possible to share the same file with different nodes.

You should create another file named perhaps system.net.config and place the entire body in there, the full

  <system.net>
    <connectionManagement>
      <add address="*" maxconnection="50"/>
    </connectionManagement>
  </system.net>

Then in the App.config you will update the system.net to be

  <system.net>
    <connectionManagement configSource="system.net.connectionManagement.config"/>
  </system.net>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!