程序更新后WCF服务不工作
我最近在我的程序中添加了 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 会更新。
I have recently added a WCF service reference to my program. When I perform a clean install of this program, everything seems to work as expected. But, when I install the program on a client which already has a previous version (without the new service reference) installed, I get a exception telling me the default endpoint for this particular service could not be found.
It seems that the appname.exe.config is not being updated with the new endpoint settings. Is there any reason for this and how can I force the installer to overwrite the config file? I'm using the default Visual Studio 2008 installer project with RemovePreviousVersions set to True.
Update:
My program encrypts the settings section after the first run with the following code
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);
}
}
}
When I do not run the program before installing the new version the app.config gets updated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,这是配置文件没有更新。
有几种可能:
尝试先卸载项目,然后安装并检查配置文件是否已被删除复制进去。
You are right that it is the config file that is not updated.
There are several possibilities:
Try uninstalling the project first, then install and check that the config file has been copied in.