Installer.Uninstall(IDictionary) 方法

定義

當在衍生類別中被覆寫時,移除安裝。When overridden in a derived class, removes an installation.

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

參數

savedState
IDictionary

IDictionary,包含安裝完成之後電腦的狀態。An IDictionary that contains the state of the computer after the installation was complete.

例外狀況

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

解除安裝時發生例外狀況。An exception occurred while uninstalling. 這個例外狀況會被忽略,解除安裝會繼續進行。This exception is ignored and the uninstall continues. 不過,解除安裝完成之後,應用程式可能沒有完全解除安裝。However, the application might not be fully uninstalled after the uninstallation completes.

範例

下列範例示範UninstallInstaller方法。The following example demonstrates the Uninstall method of Installer. 方法會在的衍生Installer類別中覆寫。 UninstallThe Uninstall method is overridden in the derived class of Installer.

   // Override 'Uninstall' method of Installer class.
public:
   virtual void Uninstall( IDictionary^ mySavedState ) override
   {
      if ( mySavedState == nullptr )
      {
         Console::WriteLine( "Uninstallation Error !" );
      }
      else
      {
         Installer::Uninstall( mySavedState );
         Console::WriteLine( "The Uninstall method of 'MyInstallerSample' has been called" );
      }
   }
// Override 'Uninstall' method of Installer class.
public override void Uninstall( IDictionary mySavedState )
{  
   if (mySavedState == null)
   {
      Console.WriteLine("Uninstallation Error !");
   }
   else
   {
      base.Uninstall( mySavedState );
      Console.WriteLine( "The Uninstall method of 'MyInstallerSample' has been called" );
   }
}
' Override 'Uninstall' method of Installer class.
Public Overrides Sub Uninstall(mySavedState As IDictionary)
   If mySavedState Is Nothing Then
      Console.WriteLine("Uninstallation Error !")
   Else
      MyBase.Uninstall(mySavedState)
      Console.WriteLine("The Uninstall method of 'MyInstallerSample' has been called")
   End If
End Sub

給繼承者的注意事項

-如果您覆寫Install(IDictionary)衍生類別中的方法, 請務必先在衍生的方法中Install(IDictionary)呼叫基類的方法。- If you override the Install(IDictionary) method in a derived class, be sure to call the base class's Install(IDictionary) method first in your derived method. 方法會呼叫這個實例之Installers屬性中包含的每個安裝程式的方法。Install(IDictionary) Install(IDictionary)The Install(IDictionary) method calls the Install(IDictionary) method of each installer contained in the Installers property of this instance. 在包含的安裝程式執行之後, 這個方法IDictionary會更新物件 ( stateSaver透過參數指定), 以反映安裝的狀態。After the contained installers run, this method updates the IDictionary object (specified through the stateSaver parameter) to reflect the status of the installation. IDictionary 傳遞Install(IDictionary)至方法時, 應該是空的。The IDictionary should be empty when passed to the Install(IDictionary) method. 如果所有Install(IDictionary)方法都成功Commit(IDictionary) , 則會呼叫方法。If all the Install(IDictionary) methods succeed, the Commit(IDictionary) method is called. 否則, Rollback(IDictionary)會呼叫方法。Otherwise, the Rollback(IDictionary) method is called.

-如果您需要Installers Install(IDictionary)在方法中將安裝程式實例新增至集合, 請務必在Uninstall(IDictionary)方法中對集合執行相同的新增專案。- If you need to add installer instances to the Installers collection in the Install(IDictionary) method, be sure to perform the same additions to the collection in the Uninstall(IDictionary) method. 不過, 如果您在自訂安裝程式的類別函式中將安裝程式實例Installers新增至集合, 則可以避免在這兩種方法中維持集合。However, you can avoid maintaining the collection in both methods if you add installer instances to the Installers collection in the class constructor for your custom installer.

適用於

另請參閱