How to prevent Visual Studio from prompting to update .settings file from app.config

梦想的初衷 提交于 2019-12-08 21:01:00

问题


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.

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".

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?


回答1:


Options>Environment>Documents>Auto-load changes, if saved (checkbox)




回答2:


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

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.

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.

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



来源:https://stackoverflow.com/questions/3920331/how-to-prevent-visual-studio-from-prompting-to-update-settings-file-from-app-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!