none
Hook into ClickOnce uninstall process? RRS feed

  • Question

  • Hello,

    For a .NET application installed using ClickOnce, is there any way to run code during the uninstall process?

    I need to update a database install count that I set during the ClickOnce first run. I hope there's an equivalent method, that I can hook, during the uninstall process.

    Any suggestions?

    Thanks in advance.

    Victor

    Thursday, December 10, 2009 5:33 AM

Answers

  • Hi Victor,

    Unlike MSI, ClickOnce doesn’t support custom action or something similar to let user take action when uninstall happens. As far as I know, there is no way to detect that action.

    Sincerely,
    Kira Qian
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    Thursday, December 10, 2009 9:40 AM

All replies

  • Hi Victor,

    Unlike MSI, ClickOnce doesn’t support custom action or something similar to let user take action when uninstall happens. As far as I know, there is no way to detect that action.

    Sincerely,
    Kira Qian
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    Thursday, December 10, 2009 9:40 AM
  • The click once uninstall happens in .net framework, there is no way to hook in your own code.

    Dan
    Thursday, December 10, 2009 4:44 PM
  • Very disappointing.

    I have developed on Microsoft technology for over 15 years, and frankly have seen API's exposing some of the most arcane machine functionality you could think of.

    So wouldn't it be cool for ClickOnce to call back into a "LastRun" method in the assembly before it is uninstalled? Or let developers hook into the uninstall process by registering an assembly that gets called during uninstall. This works better since only applications that register for uninstall notification would get it.

    Just Food for thought.

    Thanks for your quick response.

    Victor
    Thursday, December 10, 2009 6:07 PM
  • Yes, it would be cool. I've mentioned this to one of the ClickOnce team members, but don't know if they will add it to the list for the next version of not. Not in VS2010/.NET 4.0, but maybe the one after that.

    RobinDotNet
    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    Friday, December 11, 2009 9:38 AM
    Moderator
  • Clickonce is one of those technologies that looks great, feels great on a PDC booth... all the delight and joy quickly comes crashing when you actually need to do some 'expected' stuff, like uninstalling your SQL Express instance. 
    VB.NET to C# http://www.developerfusion.com/tools/convert/vb-to-csharp/
    Wednesday, January 6, 2010 7:09 PM
  • Do setup & deployment packages uninstall prerequisites? I didn't think so, but do they?

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    Thursday, January 7, 2010 4:21 PM
    Moderator
  • As DDarwin stated above, you cannot get the uninstall to do what is needed. I am exploring using traditional msi installation with click once to get it there and installed. Next is exploring using a different click once to uninstall the "main application" and then itself as a custom post commit action.

    It may also be possible using a hybrid msi/cick once process, see http://windowsclient.net/wpf/starter-kits/sce/sce-clickonce-msi-hybrid-setup.aspx 

    Some approaches seem to have a customized bootstrap installer.

    I have not seen out-of-the-box click once uninstall system level prerequisites. Since most prerequisites are an example of modifying the system rather than the user's application environment, then it is a case of install/remove per user versus install/remove for all users. An "unintentional side effect", software bloat sells more hardware.

    I have a similar problem where I need to create a unique event log the first time an applicaiton is installed. That code must be run at full trust and with administrative access to create the new event log.

    Effectively, the approach being explored is creating a traditional setup/deployment project with msi, package it up (manual process) and invoke that msi as a custom prerequisite for the click once. There is a bit about this "Adding Custom Prerequisites" at http://msdn.microsoft.com/en-us/library/ms165429(VS.80).aspx 

    It sounds possible, but like lots of things, you would have to try it to see if it can be made to work.

    Regards, Ira

    Monday, March 8, 2010 4:04 PM