在Visual Studio中合并多个配置文件 [英] Combining multiple config files in Visual Studio

查看:211
本文介绍了在Visual Studio中合并多个配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2008中有一个解决方案,其中包含多个C#项目.每个项目都有自己的配置文件(App.config和Settings.settings).这在架构上是有意义的,因为每个模块都是自治的,并在许多不同的解决方案中使用.

I have a solution in Visual Studio 2008 which contains multiple C# projects. Each project has it's own config file (App.config and Settings.settings). This makes sense architecturally as each module is autonomous and is used in a number of different solutions.

我的问题是,当我编译解决方案时,仅包含启动项目(或包含可执行文件的项目)的配置文件.对于其他模块,将配置设置编译到DLL中.所以我的问题是,在Visual Studio中,有没有办法组合多个配置文件或链接它们,以便可以在运行时更改DLL的设置?

My problem is that when I compile the solution only the config file for the startup project (or project containing the executable) is included. For other modules the config settings are compiled into the DLL. So my question is, is there any way in Visual Studio of combining multiple config files, or linking them so that settings for DLLs can be changed at runtime?

推荐答案

我不确定这是否是您要寻找的东西,或者是否有帮助,只是作为一个潜在的探索领域,请注意,您可以链接两个配置文件.例如,我将连接字符串存储在一个单独的文件中,因此Web.config中的connectionStrings行显示为:

I'm not sure if this is what you are looking for or if it will help but just as a lead into an area to explore, note that you can link two Config files. For example, I have my connection string in a separate file so my connectionStrings line in Web.config reads:

<connectionStrings configSource="WebCS.config"/>

然后,在单独的文件中,我有:

Then, in the separate file, I have:

<connectionStrings>
    <add name="BSDIConnString" 
         connectionString="Data Source=XXX;Initial Catalog=XXX;User ID=XXX;Password=XXX" 
         providerName="System.Data.SqlClient"/>
</connectionStrings>

这篇关于在Visual Studio中合并多个配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆