Installer.Rollback(IDictionary) 方法


當在衍生類別中被覆寫時,還原電腦安裝之前的狀態。When overridden in a derived class, restores the pre-installation state of the computer.

 virtual void Rollback(System::Collections::IDictionary ^ savedState);
public virtual void Rollback (System.Collections.IDictionary savedState);
abstract member Rollback : System.Collections.IDictionary -> unit
override this.Rollback : System.Collections.IDictionary -> unit
Public Overridable Sub Rollback (savedState As IDictionary)



IDictionary,包含電腦在安裝前的狀態。An IDictionary that contains the pre-installation state of the computer.


savedState 參數為 nullThe savedState parameter is null.

-或--or- IDictionary 的儲存狀態可能已經損毀。The saved-state IDictionary might have been corrupted.

在安裝的 Rollback(IDictionary) 階段時發生例外狀況。An exception occurred during the Rollback(IDictionary) phase of the installation. 這個例外狀況會被忽略,復原會繼續進行。This exception is ignored and the rollback continues. 不過,復原完成之後,電腦可能無法完全還原至其初始狀態。However, the computer might not be fully reverted to its initial state after the rollback completes.


下列範例示範RollbackInstaller方法。The following example demonstrates the Rollback method of Installer. 方法會在的衍生Installer類別中覆寫。 RollbackThe Rollback method is overridden in the derived class of Installer. 系統會產生一個例外狀況, 以強制執行安裝復原。An exception is generated to force an installation rollback.

   // Override 'Rollback' method of Installer class.
   virtual void Rollback( IDictionary^ mySavedState ) override
      Installer::Rollback( mySavedState );
      Console::WriteLine( "The Rollback method of 'MyInstallerSample'" +
                         " has been called" );
// Override 'Rollback' method of Installer class.
public override void Rollback( IDictionary mySavedState )
   base.Rollback( mySavedState );
   Console.WriteLine( "The Rollback method of 'MyInstallerSample'" +
                     " has been called" );
' Override 'Rollback' method of Installer class.
Public Overrides Sub Rollback(mySavedState As IDictionary)
   Console.WriteLine("The Rollback method of 'MyInstallerSample'" + _
                                                " has been called")
End Sub


當您覆寫Rollback(IDictionary)衍生類別中的方法時, 請務必先在衍生的方法Rollback(IDictionary)中呼叫基類的方法。When you override the Rollback(IDictionary) method in a derived class, be sure to call the base class's Rollback(IDictionary) method first in your derived method. 復原作業會將電腦還原到安裝發生之前的狀態。A rollback operation restores the computer to the state it was in before the installations occurred. 如果這個實例的Installer方法或安裝程式集合中的任何安裝程式無法正確執行, 則會呼叫方法。Rollback(IDictionary) Install(IDictionary)The Rollback(IDictionary) method is called if the Install(IDictionary) method of this instance of Installer, or any installer in the installer collection, fail to run correctly. 在安裝程式集合中呼叫Rollback(IDictionary)安裝程式的方法所產生的任何例外狀況都會被忽略, 而其他安裝程式的回復則會繼續進行。Any exceptions generated by calling the Rollback(IDictionary) methods of the installers in the installer collection are ignored and the rollback of the other installers continues.