且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WiX。取消安装时回滚自定义操作

更新时间:2022-02-28 08:31:24

安装始终在事务中完成。当您启动安装程序时,它首先会创建一个称为安装脚本的内容,类似于安装过程中要做的事情的待办事项清单。
当我们将某些自定义操作设置为 Execute = immediate 时,它将立即执行,但是当我们将操作设置为 Execute = deferred 时,它将获得添加到安装脚本中,因此回滚变得很容易。
现在要注意的一件事是,我们可以以 Execute = immediate 模式访问会话,但是我们不能以 Execute = deferred 访问会话模式。
如果我们尝试访问会话,它将给出错误,在这种情况下,这可能是您出错的原因...

Installation is always done in transaction. when you launch an installer, it first creates something called installation script which is like a to do list of what it will do while installation. When we set some custom action as Execute="immediate", it gets executed immediately but when we set our action as Execute="deferred", it gets added in the installation script, hence rollback becomes easy for this. Now one thing to note here is that we get access to session in Execute="immediate" mode, but we cannot access session in Execute="deferred" mode. If we try to access session it will give error, which in this case might be the reason for your error...