Bewerken

Share via


ServiceInstaller.Uninstall(IDictionary) Method

Definition

Uninstalls the service by removing information about it from the registry.

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

Parameters

savedState
IDictionary

An IDictionary that contains the context information associated with the installation.

Exceptions

The Service Control Manager could not be opened.

-or-

The system could not get a handle to the service.

Remarks

Uninstall first attempts to stop the service before uninstalling it. If the service cannot be stopped, no exception is caught, and the method continues with the removal of the service.

Normally, you will not call the methods on ServiceInstaller within your code; they are generally called only by the install utility. InstallUtil is used to uninstall services as well as install them; uninstalling takes a switch in the command line call.

An application's uninstall routine maintains information automatically about the components being uninstalled, using the project installer's Installer.Context. This state information, passed into Uninstall as the savedState parameter, is continuously updated as the ServiceProcessInstaller instance and each ServiceInstaller instance is installed by the utility. It is usually unnecessary for your code to modify this state information explicitly.

For all classes deriving from the Installer class, the state of the Installers collection must be the same in the Install and Uninstall methods. However, you can avoid the maintenance of the collection across the Install and Uninstall methods if you add installer instances to the Installers collection in your custom installer class constructor.

There is no rollback mechanism for uninstalling, so if one service fails to uninstall, this does not affect the other services (usually within the same installation project) being uninstalled.

Applies to

See also