zoukankan      html  css  js  c++  java
  • 利用ClickOnce升级中对App.Config和User.Config的处理的解惑

    最近有一疑问。

    我们会把应用程序范围的设置存放到App.Config文件中,会把用户的个性化数据存放到User.config文件中,然后利用ClickOnce技术将其部署到客户端,问题是,当用户利用ClickOnce升级应用程序的新版本时,这2个配置文件中的内容如何升级?比如,如果我们的系统在User.Config文件中记录了用户最后一次关闭系统时系统主窗体的位置,那么在用户升级新版的时候,这些信息是否会随着新版本的下发而丢失?最终找到的解释是:

    版本升级

    如同 ClickOnce 应用程序的每个版本独立于所有其他版本一样,ClickOnce 应用程序的应用程序设置也独立于其他版本的设置。当您的用户升级到应用程序的更高版本时,应用程序设置将最新(具有最大编号)版本的设置与随更新版本提供的设置进行比较,并将这些设置合并到一组新的设置文件中。

    下表描述应用程序设置如何决定要复制哪些设置。

     
    更改类型 升级操作

    设置添加到 app.exe.config

    新设置被合并到当前版本的 app.exe.config 中

    设置从 app.exe.config 中移除

    旧设置从当前版本的 app.exe.config 中移除

    设置的默认值更改;本地设置在 user.config 中仍设置为原始默认值

    设置被合并到当前版本的 user.config 中,以新的默认值作为其值

    设置的默认值更改;设置在 user.config 中设置为非默认值

    设置被合并到当前版本的 user.config 中,保留该非默认值

    最后2个更改类型没有看明白(悟性不高),最后才找到答案
    If you are migration from V2 to V3 where both version, there is some logic done for migrating the settings.  If the setting is application-scoped (a read-only setting) the value will be taken from the V3 version of the config file. If the setting is user-scoped (a read/write setting), the story gets more confusing.  If the value of the setting changes from V2 to V3 and the user has not changed the value of the setting, the value from the V3 config is used.  If the value of the setting changes from V2 to V3 and the user has changed the value of the setting, the value from the user config is used.  (These scenarios assume the type of the setting does not change.)

    看来,首先,似乎app.config文件正常情况下系统运行的时候是无法修改的。而对于user.config文件,只要用户修改过当初部署时的默认值,那么这些用户设置的值将在版本升级中得到保留,不会被我们新版本中的“默认值”覆盖掉,而如果用户没有修改过升级前的版本中的默认值,则这些默认值会被新版本中的默认值替换,看来Framework有一种机制来监视这些默认是是否被用户改动过。

  • 相关阅读:
    Silerlight 控制datagrid控件多选时不显示详细信息
    正则表达式限制文本框只能输入数字,小数点,英文字母,汉字
    图片正则表达式
    css最小高度,最大高度important
    让网页变灰色兼容各种浏览器
    edecms v5.7模块管理列表为空没有内容
    统一日志的记录格式,用宏调用printf
    出差
    使窗体在指定窗口的顶层
    C BNF grammar
  • 原文地址:https://www.cnblogs.com/Ricky81317/p/611948.html
Copyright © 2011-2022 走看看