我有 clickonce 应用程序,其中一项要求是即使在应用程序正在运行时也要卸载该应用程序。所以我创建了一个 MSI 包装器,它安装 clickonce 应用程序,更新注册表等,也用于卸载 clickonce 应用程序。
项目结构
- ClickOnce 应用程序 - 部署到服务器http://someserver/app.client.application。
- 控制台应用程序 1
- 这会在安装 MSI 时启动一个调用上述 url 的进程
- 在 MSI 卸载时,如果 clickonce 应用程序正在运行,则应用程序已关闭/终止,将读取 clickonce 卸载字符串并启动一个进程以尝试卸载 clickonce 应用程序
- 控制台应用程序 2 在安装时创建事件日志源并在卸载时删除它
- MSI Wrapper - 用于安装和卸载 clickonce 应用程序。
这有自定义操作集
- Install
* Primary output from console Application 2
* Primary output from console Application 1
- Uninstall
* Primary output from console Application 1
* Primary output from console Application 2
控制台应用程序 1 和 2 连接到安装程序上的 BeforeInstall 和 AfterInstall 事件。
我安装时一切正常,事件日志源被创建,clickonce 应用程序启动并安装。安装部分运行顺利,我没有问题。
但是我在卸载时遇到问题,MSI 会自行卸载并调用卸载 clickonce 的过程,这会引发提示并删除事件日志源。
以下是错误详情
有一个弹出窗口显示“卸载应用程序未成功。请参阅详细信息以获取更多信息'。
单击详细信息按钮打开错误详细信息文本
PLATFORM VERSION INFO
Windows : 6.1.7600.0 (Win32NT)
Common Language Runtime : 4.0.30319.239
System.Deployment.dll : 4.0.30319.1 (RTMRel.030319-0100)
clr.dll : 4.0.30319.239 (RTMGDR.030319-2300)
dfdll.dll : 4.0.30319.1 (RTMRel.030319-0100)
dfshim.dll : 4.0.31106.0 (Main.031106-0000)
IDENTITIES
Deployment Identity : XXXXX.Client.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=msil
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Error occurred during store lookup, component store may have been corrupted. Following failure messages were detected:
+ Application is not installed.
* Error occurred during uninstall of the application. Following failure messages were detected:
+ Application is not installed.
* Exception occurred during uninstall of application XXXXX.Client.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=msil. Following failure messages were detected:
+ Shortcut removal could not be completed. Publisher or product value is not valid.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
* [4/17/2012 10:52:36 AM] : Looking up information from component store.
* [4/17/2012 10:52:36 AM] : Uninstall of application XXXXX.Client.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=msil did not succeed.
ERROR DETAILS
Following errors were detected during this operation.
* [4/17/2012 10:52:36 AM] System.Deployment.Application.DeploymentException (SubscriptionState)
- Application is not installed.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SubscriptionStore.CheckInstalled(SubscriptionState subState)
at System.Deployment.Application.SubscriptionStore.CheckInstalledAndShellVisible(SubscriptionState subState)
at System.Deployment.Application.DeploymentServiceCom.MaintainSubscriptionInternal(String textualSubId)
* [4/17/2012 10:52:36 AM] System.Deployment.Application.DeploymentException (SubscriptionState)
- Application is not installed.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SubscriptionStore.CheckInstalled(SubscriptionState subState)
at System.Deployment.Application.SubscriptionStore.UninstallSubscription(SubscriptionState subState)
at System.Deployment.Application.DeploymentServiceCom.MaintainSubscriptionInternal(String textualSubId)
* [4/17/2012 10:52:36 AM] System.Deployment.Application.DeploymentException (Subscription)
- Shortcut removal could not be completed. Publisher or product value is not valid.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.ShellExposure.RemoveSubscriptionShellExposure(SubscriptionState subState)
at System.Deployment.Application.DeploymentServiceCom.MaintainSubscriptionInternal(String textualSubId)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available.
我尝试了多种方法,但似乎没有任何效果
- 从注册表中读取卸载字符串并启动一个进程。
- 创建了一个 vbsript 并将其添加为自定义操作。(objShell.Run“rundll32.exe dfshim.dll,ShArpMaintain XXXXX.Client.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=msil”)
- 创建了一个 cmd/bat 文件(包含 rundll32.exe dfshim.dll,ShArpMaintain XXXXXX.Client.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=msil)并在卸载时启动它。
所有这三种方法都会引发相同的错误。但是当我单独运行它们时,它们似乎都可以工作。我已经尝试了超过 2 天,把我所有的头发都拔了出来。