从另一个文件App.Config中的负载部分 [英] Load parts of App.Config from another file
问题描述
我喜欢我的的app.config
分成用户特定部分和应用特定部分。 ?是否有可能的的app.config
的一部分存储在另一个文件
I like to split my app.config
into a user specific part and an application specific part. Is it possible to store a part of the app.config
in another file?
我试过媒体链接如下:
<!DOCTYPE cruisecontrol [<!ENTITY email SYSTEM "email.config">] >
但是,这并不加载。
but this does not load.
有没有在不改变应用程序本身的另一种可能?
Is there another possiblity without changing the application itself?
推荐答案
您可以使用 configSource $ C 。$ C>属性,告诉框架加载另一个文件中的特定部分。
You can use the configSource
attribute to tell the framework to load a particular section from another file.
例如,如果你有一个配置文件,这样的内容:
For example, if you had a config file with a section like this:
<connectionStrings>
<add name="MyDatabase" connectionString="...etc..." />
</connectionStrings>
您可以将其替换为:
<connectionStrings configSource="ConnectionStrings.config" />
...并创建一个文件 ConnectionStrings.config
与原来部分的内容(包括<是connectionStrings>
节点 - 完全一样,我上面的第一个代码段)。
...and create a file ConnectionStrings.config
with the contents of the original section (including the <connectionStrings>
node - exactly the same as my first code section above).
这篇关于从另一个文件App.Config中的负载部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!