是否AppSettings的文件属性覆盖是什么在App.config? [英] Does the appsettings file attribute override what is in the app.config?

查看:300
本文介绍了是否AppSettings的文件属性覆盖是什么在App.config?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在App.config中的AppSettings标签具有文件属性:

 <文件的appSettings =other.config>
..
..
< /的appSettings>

这是如何工作的?它会合并是什么在的appSettings(原件)与other.config文件?还是会覆盖它吗?如果该other.config文件不存在,应该会崩溃?

我想它自己,如果一个关键不在原来,它似乎并没有从other.config读它?

如果other.config文件刚刚XML节点,还是应该都是一个AppSettings的元素中?

 <&的appSettings GT;
  <用户用户名与GT 123 LT; /用户用户名与GT;
< /的appSettings>

 <用户用户名与GT 123 LT; /用户用户名与GT;


解决方案

  • 如果该文件不存在,它不会崩溃,它只会被忽略。

  • 外部配置必须包含的appSettings节点,以便您的第一个例子是正确的。

  • 在外部文件中的值将优先,如果没有值是present则使用的app.config值。

这是否盖掉一切?

The appsettings tag in the app.config has a file attribute:

<appSettings file="other.config">
..
..
</appSettings>

How does this work? Will it merge what is in the appSettings (original) with the other.config file? Or will it overwrite it? What if the other.config file doesn't exist, should it crash?

I'm trying it myself and if a key isn't in the original, it doesn't seem to read it from the other.config?

Should the other.config file have just xml nodes, or should it all be inside a appsettings element?

<appSettings>
  <userId>123</userId>
</appSettings>

or

<userId>123</userId>

解决方案

  • If the file doesn't exist it will not crash, it will just be ignored.
  • The external config has to contain the appSettings node so your first example is correct.
  • The value in the external file will take priority, if no value is present then the app.config value is used.

Does that cover off everything?

这篇关于是否AppSettings的文件属性覆盖是什么在App.config?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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