开发者

How can I move app.config to a different folder inside the Solution Explorer?

I'm using Visual Studio 2010. In my Solution Explorer I like to sort my Project items into folders (a folder for Forms, a folder for Classes, a Misc folder, etc.)

It seems though that if I move the "app.config" file to a folder named "Config Files" everything works until I change a setting in the Settings.settings file. Once I do that, a new app.config is created and the one that was in the "Config Files" f开发者_开发问答older did not get updated.

I have searched the entire solution for the text "app.config" and did not find any results. How can I move this file so that my Solution Explorer looks nice and clean?


No, the app.config has to be in the main project folder - but you can "externalize" any configuration section inside the app.config by using the configSource= attribute:

<connectionStrings configSource="config\db\connectionstrings.config" />
<system.net>
  <mailSettings>
    <smtp configSource="config\mail\smtp.dev.config" />
  </mailSettings>
</system.net>
<system.serviceModel>
    <behaviors configSource="config\wcf\behaviors.config" />
    <binding configSource="config\wcf\bindings.config" />
    <client configSource="config\wcf\client.config" />
</system.serviceModel>


AFAIK, you cannot change the location of the default configuration file. Although if you need another configuration file, you can make use of ExeConfigurationFileMap class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜