Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Three questions about custom actions (more then one action, Cancelled Untinstall, and so on)
 

Three questions about custom actions (more then one action, Cancelled Untinstall, and so on)

Hi, Guys.

I have questions about Uninstall process. I use MS VS 2005(C#). I have to use Setup and Deploy project, this is a restriction of product. In the my install process I need to have a custom action to make subscriptions to QuickBooks events, register COM Automation object and make Access DB file, checking if user used before the installer and already have Access DB file. Well, actually it does not meter what should action do. But it is important what this process not so fast. Actually it is several actions, as you can see.

1. And here is the first question: How can I add several custom actions in certain sequence in the Install node? Currently I just have one additional DLL which contains Installer1 class and make all job inside overridden Install method calling internal private methods in necessary sequence to make all job. It looks ugly. But I do not know how to use Installer1, Installer2, Installer3,etc classes if they are placed in the one assembly\DLL (CustomInstallers.dll) , because when I add Project Output I can set only assembly not a class Please help me.

2. When customer uninstalls application other custom action is run and does contrary acts. Currently it works like one custom action, but I prefer to separate it to several custom action, but do not know how I ca make it. This is the same problem like I have described above. But a really problem happens when customer pushes Cancel button during the uninstallation process. I need to catch this event to analyze which part of custom action has been done and which part should be rollbacked. How can I do it? Please advise.

3. I tied to use OnBeforeUninstal and OnAfterUninstall overridden methods �no luck. I even do not why it works so incorrect. This is simplest example from my Installer1 class:

public override void Uninstall(IDictionary savedState)

{

base.Uninstall(savedState);

MessageBox.Show("Uninstall");

}

protected override void OnBeforeUninstall(IDictionary savedState)

{

MessageBox.Show("OnBeforeUninstall");

base.OnBeforeUninstall(savedState);

}

protected override void OnAfterUninstall(IDictionary savedState)

{

base.OnAfterUninstall(savedState);

MessageBox.Show("OnAfterUninstall");

}

During uninstallation process I see next sequence of messages: OnBeforeUninstall, OnAfterUninstall, Uninstall. But I was sure that it should be OnBeforeUninstall, Uninstall, OnAfterUninstall. Could someone explain it?

Thank you

Ant7400246  Friday, April 13, 2007 12:22 PM

1. Just add another custom action from another Dll or assembly.

2. You shouldn't need to worry about this. The uninstall keeps track of what's going on and when it gets canceled it restores what was uninstalled. You don't need a rollback custom for an uninstall.

3. Before and after are a bit misleading here. I believe the sequence here is:

a) base.Uninstall gets called, and this code calls OnBeforeInstall as it starts and OnAfterInstall when it finishes.

b) base.Uninstall exits into your code and your messagebox says Uninstall.

The key here is that OnBeforeX and OnAfterX are not actually called before or after X - they're called atthe start of X and then just before it exits.

PhilWilson  Friday, April 13, 2007 8:13 PM

Thank you for your answer about #1 and #3, but it is not clear for me about #2. Can your clarify something for me please.

I have a custom action which works long period of time. When I uninstall application I run other custom action which makes opposite acts. During uninstallation and when custom action is working a user can push Cancel button. In such case the custom action finishes his work and then uninstaller reacts to Cancel click event. It looks like the user can push the button during custom action is working but a reaction appears after the custom action is finished. And then unsinstaller starts rollback uninstallation process, i.e. restores just deleted files which are part of the application, for instances. Here I need to run my custom action to ensure that all works properly, I mean like before the user started uninstallation process.

Speaking about Setup and Deployment projects, I know that I can use Rollback and Commit overridden methods. But they work only after method Install is called, and we have information about it in the MSDN. In my case I use Uninstall overridden method. I know that Setup and Deployment projects not so h-mmm wide. Well, I spend about four days trying to solve the problem, please help my. I am even ready to use WiX and Orca, even more I am ready to go to the Moon to solve my issue.

Thank you

Ant7400246  Thursday, April 19, 2007 9:58 AM

You can use google to search for other answers

Custom Search

More Threads

• "New Programs Installed" notification on ClickOnce Update
• Localized Deployment, localized .NET installer
• Setup Program Validation Error
• CD for install and Click-once for upgrades
• User Settings not upgrading in ClickOnce
• Global assembly cache error while publishing
• Install ClickOnce with Group Policy Software Installation
• Setup Project produces both a MSI file and a setup.exe file.
• Param Tag Issue in IE
• Cannot add a file to a Visual Studio setup project