c# - 为什么我的 Uninstall 方法没有从 msi 调用?

标签 c# .net installation windows-installer

我正在为我的网络应用程序编写安装程序,但我在卸载程序部分遇到了困难。尽管我在我的应用程序设置项目中创建了一个关于卸载的自定义操作,但 InstallerClass 设置为 true,方法:

public override void Uninstall(IDictionary savedState)
    {
        //MessageBox.Show("Attach debugger!", "Viper.Setup");
        Cleanup();
        base.Uninstall(savedState);
    }

似乎没有调用安装程序类。任何想法可能是什么原因?

编辑:我还注意到它不仅不运行安装程序,而且不删除我的主 dll 文件。更糟糕的是,当我卸载前一个版本后安装新版本时,这个dll仍然是旧版本(即使安装和卸载都成功)

最佳答案

您是否将安装程序代码的输出包含在安装程序的“代码操作”选项卡中?

如果不是这样的话......

我过去遇到过类似的问题,发现我需要定义所有 4 种方法,否则卸载将无法运行。将您的代码添加到下面的模板中:

[RunInstaller(true)]
public class MyInstaller: Installer
{
    public override void Install(IDictionary stateSaver)
    {
        base.Install(stateSaver);
    }

    public override void Commit(IDictionary savedState)
    {
        base.Commit(savedState);
    }

    public override void Rollback(IDictionary savedState)
    {
        base.Rollback(savedState);
    }

    public override void Uninstall(IDictionary savedState)
    {
        base.Uninstall(savedState);
    }
}

希望这对您有所帮助!

关于c# - 为什么我的 Uninstall 方法没有从 msi 调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/667261/

相关文章:

c# - Linq-to-SQL 加载 1 :1 Relations in a single query

.net - 使用 IDataErrorInfo 和 MVVM 模式问题进行数据验证

Java 应用程序 SWT : Update UI on thread finished

python - 没有名为 '_gdbm' 的模块

c - ubuntu 上的 libgtk 版本问题

c# - 如何将带空格的字符串传递给 converterParameter?

c# - 为什么 "while"在 C# 中如此流行?

.net - 字典何时在 Add 或 ContainsKey 上抛出 IndexOutOfRangeException?

ubuntu - 文件夹不一致:Hadoop中的存储目录

c# - 如何在 SQLite.net 中查询 View ?