Custom action exception during Rollback

In a custom action, I override the following function and get an exception in the rollback case ...

"The saved dictionary contains the expected values ​​and may have been corrupted."

Is there any other way to rollback?

   protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
    {            
        try
        {                

            bool report = false; //Some validation
            if (!report)                
                throw new InstallException("License is not valid.");
            base.OnBeforeInstall(savedState);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            base.Rollback(savedState);
        }

    }
+3
source share
2 answers

Change "base.Rollback ()" in the exception handler to "throw;". Your caller will cancel at the right time.

+1
source

pinvoke . - installexception.

+1

Source: https://habr.com/ru/post/1731167/


All Articles