C# ClickOnce 应用程序替换当前安装的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11921404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 19:43:24  来源:igfitidea点击:

ClickOnce application replace current installed fliles

c#clickonce

提问by Oliver Kucharzewski

With ClickOnce applications, is it possible to replace the current files or install in a different directory when creating a new version? Because the error I get is:

使用 ClickOnce 应用程序,是否可以在创建新版本时替换当前文件或安装在不同的目录中?因为我得到的错误是:

Unable to install this application because an application with the same identity is already installed. To install this application, either modify the manifest version for this application or uninstall the preexisting application.

无法安装此应用程序,因为已安装具有相同标识的应用程序。要安装此应用程序,请修改此应用程序的清单版本或卸载先前存在的应用程序。

采纳答案by Wiktor Zychla

As the error message says, there are two options.

正如错误消息所说,有两个选项。

First, you as a developer should modify the version number of the ClickOnce manifest. This is done at the ClickOnce tab of the project settings. Note that ClickOnce version has nothing in common with your assembly (assemblies) version.

首先,您作为开发人员应该修改 ClickOnce 清单的版本号。这是在项目设置的 ClickOnce 选项卡中完成的。请注意,ClickOnce 版本与您的程序集(程序集)版本没有任何共同之处。

Another option is to uninstall the application and unfortunately, this probably has to be done manually. You have to find the ClickOnce deployment folder (C:\Users\username\AppData\Local\Apps\2.0) and manually delete all folder contents. This can also be done by invoking the

另一种选择是卸载应用程序,不幸的是,这可能必须手动完成。您必须找到 ClickOnce 部署文件夹 ( C:\Users\username\AppData\Local\Apps\2.0) 并手动删除所有文件夹内容。这也可以通过调用

 rundll32 dfshim CleanOnlineAppCache

command from the commandline.

来自命令行的命令。

回答by MikeyZorro

I also found that both rundll32 dfshim CleanOnlineAppCacheor mage.exe -ccdon't seem to work, I still get the same error.

我还发现两者rundll32 dfshim CleanOnlineAppCachemage.exe -cc似乎都不起作用,我仍然遇到相同的错误。

I have manually deleted the deployment folder.

我已经手动删除了部署文件夹。

On Windows XP the path to deployment folder would be C:\Documents and Settings\UserName\Local Settings\Apps.

在 Windows XP 上,部署文件夹的路径为C:\Documents and Settings\UserName\Local Settings\Apps.

回答by Greg Netland

When I encountered this error it is because I wanted two different install locations for the same program. Specifically Program_A was published to two spots online and after changing a small thing in the program, I wanted them to both be installed on the same machine, but from different ClickOnce links.

当我遇到这个错误时,是因为我想要同一个程序有两个不同的安装位置。特别是 Program_A 被发布到网上的两个地方,在程序中更改了一个小东西后,我希望它们都安装在同一台机器上,但是来自不同的 ClickOnce 链接。

So after receiving that error, instead of attempting to tweak the manifest I changed the options. Project Settings -> Publish -> Options -> I edited [Published Name, Suite name:, Product name:]. You may not have to change all three.

因此,在收到该错误后,我没有尝试调整清单,而是更改了选项。项目设置 -> 发布 -> 选项 -> 我编辑了 [发布名称,套件名称:,产品名称:]。您可能不必更改所有三个。

I now have both installs running. ClickOnce will install in a different directory, but it will remove the first desktop shortcut.

我现在有两个安装运行。ClickOnce 将安装在不同的目录中,但它会删除第一个桌面快捷方式。

If you dont want to go that route, manifest information is here.
https://msdn.microsoft.com/en-us/library/ws1c2fch.aspx

如果你不想走那条路,清单信息在这里。
https://msdn.microsoft.com/en-us/library/ws1c2fch.aspx

And your manifest is usually is located under bin/debug(release)/yourprogramname.application.

您的清单通常位于 bin/debug(release)/yourprogramname.application 下。