Why is my Uninstall method not called from the msi

2019-07-04 11:34发布

I am writing an installer for my web app and I struggle with the uninstaller part. Despite the fact that I created a custom action on Uninstall in my Application Setup Project, the InstallerClass is set to true, the method:

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

on the installer class doesn't seem to be called. Any ideas what could be the reason?

EDIT: I also noticed that it not only doesn't run the Installer, but also doesn't delete my main dll file. To make it worse, when I install a new version after uninstalling the previous one, this dll is still the old one (even though installation and uninstallation were successful)

7条回答
不美不萌又怎样
2楼-- · 2019-07-04 12:11

Got the same issue. Read the answers here, but at first sight misunderstood the helpful answer from dynaclips.

Did you include the output of your installer code in the Code Actions tab of the installer?

So here to make it more clear, screenshots...

Mising custom action

Custom actions for uninstall and rollback

And finally here the same overrides but in VB.net

Public Class Installer1

Public Sub New()
    MyBase.New()

    'This call is required by the Component Designer.
    InitializeComponent()

    'Add initialization code after the call to InitializeComponent
End Sub

<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
    MyBase.Install(stateSaver)
    YourCustomInstallAction2BeRenamed()
End Sub


<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
    MyBase.Commit(savedState)
End Sub

<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Rollback(ByVal savedState As System.Collections.IDictionary)
    MyBase.Rollback(savedState)
    YourCustomRollbackAction2BeRenamed()
End Sub

<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
    MyBase.Uninstall(savedState)
    YourCustomDeleteAction2BeRenamed()
End Sub
查看更多
登录 后发表回答