外部的AppSettings文件不是用的web.config合并 [英] External AppSettings File NOT merging with web.config

查看:240
本文介绍了外部的AppSettings文件不是用的web.config合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我用的appSettings部分中的web.config文件。 appSettings部分包含了许多应用程序使用的密钥。 appSettings部分还包含文件=AppSettings.config属性。该AppSettings.config文件然后包含值从主web.config中的一个子集。我们的想法是在web.config中包含所有基本/缺省设置,然后提供的默认值会覆盖AppSettings.config文件。

In my app, I have a web.config file with an appSettings section. The appSettings section contains a number of keys that the app uses. The appSettings section also contains the file="AppSettings.config" attribute. The AppSettings.config file then contains a subset of the values from the main web.config. The idea is for the web.config to contain all the base/default settings, and then to provide overrides of the defaults in the AppSettings.config file.

根据这个帖子( http://stackoverflow.com/a/6940086/216160 ),我的设置应该工作。(特别是:将合并(并覆盖)在config文件设置

According to this post (http://stackoverflow.com/a/6940086/216160), my setup ought to work (particularly : will merge (and override) settings in the .config file).

我看到的问题是,它不工作。我有一个false默认值,然后驱动有关显示一些测试报告功能(或没有)一些逻辑,并设置AppSettings.config覆盖此键为真。可悲的是,它继续隐藏报表系统。但是,如果我改变web.config中值,则该项显示。

The problem I'm seeing is that its not working. I have a default value of false, which then drives some logic about displaying some beta reporting functionality (or not), and have set the AppSettings.config to override this key to 'true'. Sadly, it continues to hide the report system. But, if I change the web.config value, then the item displays.

有没有可能在AppSettings的没有得到合并? 如何测试/验证真实的情况?

Is it possible that the AppSettings are not getting merged? How can I test/prove what's really happening?

看来,有一个在AppSettings.config文件某种错误。当所有的工作,因为它应该正好happeded预期合并。不过,我仍然对如何当AppSettings.config文件有某种问题的检测问题。我已经测试,以查看该文件是否是有效的XML(它是),不过不失,一些问题仍。当我复制从web.config中运行的关键,贴吧右下方从AppSettings.config非工作重点,他们似乎是相同的。我期望必须有某种方式来抛出一个错误在配置文件合并错误的事件?

It appears that there was some kind of error in the AppSettings.config file. When all is working as it should, the merge happeded exactly as expected. However, I still have the issue of how to detect when the AppSettings.config file has some kind of issue. I'd tested to see if the file was valid XML (and it was), but yet, some issue remained. When I copied the functioning key from web.config, and pasted it right below the non-working key from AppSettings.config, they appeared to be identical. I expect there must be some way to throw an error in the event of a config file merge error?

推荐答案

我刚做了同样的问题(CONFIGS不合并如预期),但经过明确删除从的/ bin和/ OBJ目录解决方案文件夹的连接performanced一个重建,一切都按预期再次,所以我建议你尝试,看看它是如何工作...

I just had the same issue (configs not merging as expected), but after explicitly deleting the /bin and /obj directories from the solution-folder en performanced a rebuild, everything worked as expected again, so I would suggest you try that and see how it works...

PS:另外,请确保您设置的外部配置的文件属性为一直拷贝。否则也不会在bin目录在您运行applicaties生命存在。

PS: Also make sure you set the file properties of the external config to 'Copy Always'. Otherwise it won't exist in the bin-directory where your running applicaties lives.

这篇关于外部的AppSettings文件不是用的web.config合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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