如何防止Visual Studio提示从app.config更新.settings文件 [英] How to prevent Visual Studio from prompting to update .settings file from app.config

查看:570
本文介绍了如何防止Visual Studio提示从app.config更新.settings文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用.settings文件来存储我们的应用程序设置,并在其中使用默认值,以便我们无需配置每个设置。这通常是很好的。

We're using a .settings file to store our application settings, and use default values in there so that we don't need to configure every single setting. This has generally been fine.

但是,在开发过程中,我们经常更改app.config中的值,这意味着当我们打开.settings文件时,您要更新.settings文件中的值吗?

However, during development we'll frequently change values in app.config, which means that when we open the .settings file, we always get the prompt "Value of setting 'x' was changed in the app.config file. Do you want to update the value in the .settings file?"

,正确的做法是始终点击否,否则开发设置可以相对轻松地滑入测试和生产环境。但是,因为我们是人类,这并不总是会发生什么。更糟糕的是,默认按钮是是。

In our case, the correct thing to do is always click No, otherwise development settings can slip through to test and production environments with relative ease. But, since we're human, that's not always what happens. What's worse, the default button is "Yes".

我们可以删除人的元素,让Visual Studio不问我们吗?或者我们应该放弃依赖默认设置,并在app.config中为每个环境中的每一个设置定义一个明确的条目。

Can we remove the human element somewhat and make Visual Studio not ask us this? Or should we give up on relying on default settings and define an explicit entry in app.config for every single setting in every single environment?

推荐答案

在VS2015中不工作。

Doesn't work in VS2015. No such -auto-load changes feature listed there.

请使用StringCollection尝试此操作,并阅读MSDN,了解他们为什么不想修复此已知问题。 app.config将被改变,并且看起来不同于属性文件夹下的settings.Settings文件。

Try this with a StringCollection and read MSDN as to why they are not wanting to fix this known issue. app.config will be changed and will look different than the settings.Settings file under the Properties folder.

警告仍然存在,因为字节不同,但它们对正在写入的每个文件都正常工作。设计器在一个视图中加载它,并使用数据写入您的..exe.config文件。

The warning persists because the bytes are different, yet they work correctly for each file being written into. The designer loads this in one view and uses the data to write to your ..exe.config file.

此时根据Microsoft不工作,它不是VS2015RC的功能/修复。 TESTED !!!

No work around at this time according to Microsoft and it is not a feature/fix of the VS2015RC either. TESTED!!!

这篇关于如何防止Visual Studio提示从app.config更新.settings文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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