Upraviť

Zdieľať cez


AssemblyInstaller Class

Definition

Loads an assembly, and runs all the installers in it.

public ref class AssemblyInstaller : System::Configuration::Install::Installer
public class AssemblyInstaller : System.Configuration.Install.Installer
type AssemblyInstaller = class
    inherit Installer
Public Class AssemblyInstaller
Inherits Installer
Inheritance

Examples

In the following example, an AssemblyInstaller is created by invoking the AssemblyInstaller constructor. The properties of this object are set and the Install and Commit methods are called to install the MyAssembly.exe assembly.

#using <System.dll>
#using <System.Configuration.Install.dll>

using namespace System;
using namespace System::Configuration::Install;
using namespace System::Collections;
using namespace System::Collections::Specialized;
int main()
{
   IDictionary^ mySavedState = gcnew Hashtable;
   Console::WriteLine( "" );
   try
   {
      
      // Set the commandline argument array for 'logfile'.
      array<String^>^commandLineOptions = {"/LogFile=example.log"};
      
      // Create an object of the 'AssemblyInstaller' class.
      AssemblyInstaller^ myAssemblyInstaller = gcnew AssemblyInstaller(
         "MyAssembly.exe", commandLineOptions );
      myAssemblyInstaller->UseNewContext = true;
      
      // Install the 'MyAssembly' assembly.
      myAssemblyInstaller->Install( mySavedState );
      
      // Commit the 'MyAssembly' assembly.
      myAssemblyInstaller->Commit( mySavedState );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e->Message );
   }
}
using System;
using System.Configuration.Install;
using System.Collections;
using System.Collections.Specialized;

class AssemblyInstaller_Example
{
   static void Main()
   {
      IDictionary mySavedState = new Hashtable();

      Console.WriteLine( "" );

      try
      {
         // Set the commandline argument array for 'logfile'.
         string[] commandLineOptions = new string[ 1 ] {"/LogFile=example.log"};

         // Create an object of the 'AssemblyInstaller' class.
         AssemblyInstaller myAssemblyInstaller = new
                     AssemblyInstaller( "MyAssembly.exe" , commandLineOptions );

         myAssemblyInstaller.UseNewContext = true;

         // Install the 'MyAssembly' assembly.
         myAssemblyInstaller.Install( mySavedState );

         // Commit the 'MyAssembly' assembly.
         myAssemblyInstaller.Commit( mySavedState );
      }
      catch (Exception e)
      {
         Console.WriteLine( e.Message );
      }
   }
}
Imports System.Configuration.Install
Imports System.Collections
Imports System.Collections.Specialized

Class AssemblyInstaller_Example

   Shared Sub Main()
      Dim mySavedState = New Hashtable()

      Console.WriteLine("")

      Try
         ' Set the commandline argument array for 'logfile'.
         Dim commandLineOptions(0) As String
         commandLineOptions(0) = "/LogFile=example.log"

         ' Create an object of the 'AssemblyInstaller' class.
         Dim myAssemblyInstaller As _
               New AssemblyInstaller("MyAssembly.exe", commandLineOptions)

         myAssemblyInstaller.UseNewContext = True

         ' Install the 'MyAssembly' assembly.
         myAssemblyInstaller.Install(mySavedState)

         ' Commit the 'MyAssembly' assembly.
         myAssemblyInstaller.Commit(mySavedState)
      Catch e As Exception
         Console.WriteLine(e.Message)
      End Try
   End Sub
End Class

Constructors

AssemblyInstaller()

Initializes a new instance of the AssemblyInstaller class.

AssemblyInstaller(Assembly, String[])

Initializes a new instance of the AssemblyInstaller class, and specifies both the assembly to install and the command line to use when creating a new InstallContext object.

AssemblyInstaller(String, String[])

Initializes a new instance of the AssemblyInstaller class, and specifies both the file name of the assembly to install and the command line to use when creating a new InstallContext object for the assembly's installation.

Properties

Assembly

Gets or sets the assembly to install.

CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
CommandLine

Gets or sets the command line to use when creating a new InstallContext object for the assembly's installation.

Container

Gets the IContainer that contains the Component.

(Inherited from Component)
Context

Gets or sets information about the current installation.

(Inherited from Installer)
DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
HelpText

Gets the help text for all the installers in the installer collection.

Installers

Gets the collection of installers that this installer contains.

(Inherited from Installer)
Parent

Gets or sets the installer containing the collection that this installer belongs to.

(Inherited from Installer)
Path

Gets or sets the path of the assembly to install.

Site

Gets or sets the ISite of the Component.

(Inherited from Component)
UseNewContext

Gets or sets a value indicating whether to create a new InstallContext object for the assembly's installation.

Methods

CheckIfInstallable(String)

Checks to see if the specified assembly can be installed.

Commit(IDictionary)

Completes the installation transaction.

CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose()

Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService()
Obsolete.

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService()
Obsolete.

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
Install(IDictionary)

Performs the installation.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnAfterInstall(IDictionary)

Raises the AfterInstall event.

(Inherited from Installer)
OnAfterRollback(IDictionary)

Raises the AfterRollback event.

(Inherited from Installer)
OnAfterUninstall(IDictionary)

Raises the AfterUninstall event.

(Inherited from Installer)
OnBeforeInstall(IDictionary)

Raises the BeforeInstall event.

(Inherited from Installer)
OnBeforeRollback(IDictionary)

Raises the BeforeRollback event.

(Inherited from Installer)
OnBeforeUninstall(IDictionary)

Raises the BeforeUninstall event.

(Inherited from Installer)
OnCommitted(IDictionary)

Raises the Committed event.

(Inherited from Installer)
OnCommitting(IDictionary)

Raises the Committing event.

(Inherited from Installer)
Rollback(IDictionary)

Restores the computer to the state it was in before the installation.

ToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.

(Inherited from Component)
Uninstall(IDictionary)

Removes an installation.

Events

AfterInstall

Occurs after the Install(IDictionary) methods of all the installers in the Installers property have run.

(Inherited from Installer)
AfterRollback

Occurs after the installations of all the installers in the Installers property are rolled back.

(Inherited from Installer)
AfterUninstall

Occurs after all the installers in the Installers property perform their uninstallation operations.

(Inherited from Installer)
BeforeInstall

Occurs before the Install(IDictionary) method of each installer in the installer collection has run.

(Inherited from Installer)
BeforeRollback

Occurs before the installers in the Installers property are rolled back.

(Inherited from Installer)
BeforeUninstall

Occurs before the installers in the Installers property perform their uninstall operations.

(Inherited from Installer)
Committed

Occurs after all the installers in the Installers property have committed their installations.

(Inherited from Installer)
Committing

Occurs before the installers in the Installers property commit their installations.

(Inherited from Installer)
Disposed

Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

Applies to