我在 Visual Studio 2008 中有一个解决方案,其中包含多个 C# 项目。 每个项目都有自己的配置文件(App.config 和 Settings.settings)。 这在架构上是有意义的,因为每个模块都是自治的,并且用于许多不同的解决方案中。
我的问题是,当我编译解决方案时,仅包含启动项目(或包含可执行文件的项目)的配置文件。 对于其他模块,配置设置被编译到 DLL 中。 所以我的问题是,在 Visual Studio 中是否有任何方法可以组合多个配置文件或链接它们,以便可以在运行时更改 DLL 的设置?
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.
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?
发布评论
评论(4)
我不确定这是否是您正在寻找的内容,或者它是否会有所帮助,但只是作为进入探索区域的引导,请注意您可以链接两个配置文件。 例如,我的连接字符串位于一个单独的文件中,因此 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:
Then, in the separate file, I have:
我不相信有。 但是以防万一您不知道。
I don't believe there is. But just in case you're unaware.
好的,各位好心人,您需要了解的有关 VS 配置文件的所有信息:
链接
OK good people, all you will ever need to know about VS config files:
Link
经过更多挖掘,我发现这篇文章非常有用
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/2710647c-6414-42c4-90b7-fd7603f55ae0/
以防万一有人遇到同样的问题,以上似乎是解决这个问题的最实用的方法。 但请注意,使用此解决方案创建安装包可能会变得乏味:
http://bytes.com/groups/net-c/498720-app-config-dll-not-getting-added-setup-project
After more digging, I found this quite useful post
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/2710647c-6414-42c4-90b7-fd7603f55ae0/
Just in case anyone runs into the same issue, the above seems to be the most practical way of getting around it. Although beware that with this solution creating setup packages may become tedious:
http://bytes.com/groups/net-c/498720-app-config-dll-not-getting-added-setup-project