This documentation is archived and is not being maintained.

ServiceInstaller.Uninstall Method

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
)
public void Uninstall (
	IDictionary savedState
)
public override function Uninstall (
	savedState : IDictionary
)

Parameters

savedState

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

Exception typeCondition

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.

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: