你如何管理.NET的app.config文件为大型应用程序? [英] How do you manage .NET app.config files for large applications?

查看:305
本文介绍了你如何管理.NET的app.config文件为大型应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设建立在几个基础组件封装在自己组装的大型复合应用程序:(数据库中读取,协议处理等)。对于某些部署,这包括超过20集。每个组件都有设置或配置信息。我们的团队往往喜欢VS设置编辑器(和易于使用的code它会产生!),以及应用程序与用户区分满足我们大部分的需求。

Suppose a large composite application built on several foundation components packaged in their own assemblies: (database reading, protocol handlers, etc.). For some deployments, this can include over 20 assemblies. Each of these assemblies has settings or configuration information. Our team tends to like the VS settings editor (and the easy-to-use code it generates!), and the application vs. user distinction meets most of our needs.

但....

这是非常繁琐的复制和;粘贴很多配置部分到我们的应用程序的.xml。此外,对于共享组件,往往具有跨应用程序类似的配置,这意味着我们需要保持在多个.config文件中的重复设置。

It is very tedious to copy & paste the many configuration sections into our application's .xml. Furthermore, for shared components that tend to have similar configurations across applications, this means we need to maintain duplicate settings in multiple .config files.

微软EntLib解决了这个问题与外部工具生成怪物.config文件,但这种感觉klunky以及

Microsoft's EntLib solves this problem with an external tool to generate the monster .config file, but this feels klunky as well.

你用什么技术来管理来自多个共享组件部分大型.NET .config文件?样的一些包括机制?自定义配置的读者?

What techniques do you use to manage large .NET .config files with sections from multiple shared assemblies? Some kind of include mechanism? Custom configuration readers?

后续:

威尔的<一个href="http://stackoverflow.com/questions/89245/how-do-you-manage-net-appconfig-files-for-large-applications#89618">answer正是我越来越在,看起来优雅的平键/值对部分。有没有一种方法,以这种方式与<联合收割机href="http://stackoverflow.com/questions/89245/how-do-you-manage-net-appconfig-files-for-large-applications#89618">custom配置部分的?

Will's answer was exactly what I was getting at, and looks elegant for flat key/value pair sections. Is there a way to combine this approach with custom configuration sections ?

也感谢有关不同的构建目标管理不同的.configs的建议。这也是非常有用的。

Thanks also for the suggestions about managing different .configs for different build targets. That's also quite useful.

戴夫

推荐答案

您使用指向其他配置文件一个主配置文件。 <一href="http://blog.andreloker.de/post/2008/06/Keep-your-config-clean-with-external-config-files.aspx">Here's如何做到这一点的一个例子。

You use one master config file that points to other config files. Here's an example of how to do this.

在情况下,链接腐烂,你做的是指定的<一个href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspx">configSource对于特定的配置部分。这使您可以在一个单独的文件中定义的特定部分。

In case the link rots, what you do is specify the configSource for a particular configuration section. This allows you to define that particular section within a separate file.

<pages configSource="pages.config"/>

这意味着有一个名为包含相同目录中的pages.config文件中的整个&LT;页/&GT; 节点树

这篇关于你如何管理.NET的app.config文件为大型应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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