I have a Visual Studio Setup Project with a custom action on Uninstall step.
That custom action will simply display a window where the user can enter some credentials. If the credentials are correct, I want to uninstall the app. Otherwise, I want to keep the app installed (bypass the uninstall procedure).
I created a custom Installer class like in this article.
The code adapted to my needs is the following:
public override void Uninstall(IDictionary savedState)
{
var window = new CredentialManager();
if(window.ShowDialog() == DialogResult.OK)
{
base.Uninstall(savedState);
}
}
CredentialManager is my Form that I use to get the credentials from the user and decide if they are correct or not.
I am expecting to uninstall the app only if the condition is verified but it uninstalls the app anyway! Even if I leave the Uninstall method empty, it still uninstalls the app.
Do you know a way to achieve what I want?
Thank you respectfully.
I finally done it by throwing an exception when I want to cancel the uninstall step. It is a working solution, as it allows me to provide an error message to the user and rollbacks the uninstall procedure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.