ServiceInstaller.Uninstall Method (IDictionary)

 

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

Namespace:   System.ServiceProcess
Assembly:  System.ServiceProcess (in System.ServiceProcess.dll)

public override void Uninstall(
	IDictionary savedState
)

Parameters

savedState
Type: System.Collections.IDictionary

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

Exception Condition
Win32Exception

The Service Control Manager could not be opened.

-or-

The system could not get a handle to the service.

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.

.NET Framework
Available since 1.1
Return to top
Show: