开发者

Exception in Custom Action during RollBack

开发者 https://www.devze.com 2022-12-19 14:06 出处:网络
In custom action I override following function and got exception in rollback case... \"savedState dictionary does not

In custom action I override following function and got exception in rollback case...

"savedState dictionary does not contain the expected values and might 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);
        }

    开发者_如何学C}


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


You can use pinvoke to call the cancel button on the base installer. This will rollback without any installexception error message dialogs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号