0

我最近在我的程序中添加了 WCF 服务引用。当我执行该程序的全新安装时,一切似乎都按预期工作。但是,当我在已经安装了以前版本(没有新服务参考)的客户端上安装程序时,我收到一个异常,告诉我找不到此特定服务的默认端点。

似乎 appname.exe.config 没有使用新的端点设置进行更新。有什么原因吗?如何强制安装程序覆盖配置文件?我正在使用默认的 Visual Studio 2008 安装程序项目,并将 RemovePreviousVersions 设置为 True。

更新: 我的程序在第一次运行后使用以下代码加密设置部分

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        ConfigurationSection section = config.GetSection(sectionKey);
        if (section != null)
        {
            if (!section.SectionInformation.IsProtected)
            {
                if (!section.ElementInformation.IsLocked)
                {
                    section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                    section.SectionInformation.ForceSave = true;
                    config.Save(ConfigurationSaveMode.Full);
                }
            }
        }

当我在安装新版本之前不运行程序时,app.config 会更新。

4

1 回答 1

0

You are right that it is the config file that is not updated.

There are several possibilities:

  • The installer has the old version of the config file
  • The installer does not have a config file and the program is using the old one on the machine

Try uninstalling the project first, then install and check that the config file has been copied in.

于 2009-08-26T15:20:53.990 回答