Why is my Uninstall method not being called?

2019-05-13 17:58发布

问题:

My VS 2008 created installer doesn't call the override Uninstall method in my installer class. why? The Install method was called. My installer class looks like this:

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

            //encrypt connection string
            encryptConntStr();

            //create database
            createDatabase();
        }

        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);
            System.Diagnostics.Debugger.Break();
            MessageBox.Show("I am in Uninstall now.");
            string exePathStr = Context.Parameters["targetdir"];
           ...           

        }
}

EDIT:

回答1:

make sure the CustomActionData property is not empty. Some how it was empty in my case and cause that problem.