AssemblyInstaller AssemblyInstaller AssemblyInstaller AssemblyInstaller Class

定義

載入組件,並且執行組件中的所有安裝程式。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
繼承

範例

在下列範例中,是AssemblyInstaller藉由叫用此AssemblyInstaller函式來建立。In the following example, an AssemblyInstaller is created by invoking the AssemblyInstaller constructor. 已設定這個物件的屬性,並Install呼叫和Commit方法來安裝MyAssembly.exe元件。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 ( ArgumentException^ ) 
   {
   }
   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 (ArgumentException)
      {
      }
      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 ArgumentException
      Catch e As Exception
         Console.WriteLine(e.Message)
      End Try
   End Sub
End Class 'AssemblyInstaller_Example

建構函式

AssemblyInstaller() AssemblyInstaller() AssemblyInstaller() AssemblyInstaller()

初始化 AssemblyInstaller 類別的新執行個體。Initializes a new instance of the AssemblyInstaller class.

AssemblyInstaller(Assembly, String[]) AssemblyInstaller(Assembly, String[]) AssemblyInstaller(Assembly, String[]) AssemblyInstaller(Assembly, String[])

初始化 AssemblyInstaller 類別的新執行個體,並且指定當建立新 InstallContext 物件時要安裝的組件和要使用的命令列。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[]) AssemblyInstaller(String, String[]) AssemblyInstaller(String, String[]) AssemblyInstaller(String, String[])

初始化 AssemblyInstaller 類別的新執行個體,並且指定當為組件的安裝建立新 InstallContext 物件時要安裝之組件的檔案名稱和要使用的命令列。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.

屬性

Assembly Assembly Assembly Assembly

取得或設定要安裝的組件。Gets or sets the assembly to install.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

取得值,指出元件是否能引發事件。Gets a value indicating whether the component can raise an event.

(Inherited from Component)
CommandLine CommandLine CommandLine CommandLine

取得或設定當為組件的安裝建立新 InstallContext 物件時要使用的命令列。Gets or sets the command line to use when creating a new InstallContext object for the assembly's installation.

Container Container Container Container

取得包含 IContainerComponentGets the IContainer that contains the Component.

(Inherited from Component)
Context Context Context Context

取得或設定有關目前安裝的資訊。Gets or sets information about the current installation.

(Inherited from Installer)
DesignMode DesignMode DesignMode DesignMode

取得值,指出 Component 目前是否處於設計模式。Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

取得附加在這個 Component 上的事件處理常式清單。Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
HelpText HelpText HelpText HelpText

取得安裝程式集合中所有安裝程式的說明文字。Gets the help text for all the installers in the installer collection.

Installers Installers Installers Installers

取得這個安裝程式包含的安裝程式集合。Gets the collection of installers that this installer contains.

(Inherited from Installer)
Parent Parent Parent Parent

取得或設定安裝程式,含有這個安裝程式所屬的集合。Gets or sets the installer containing the collection that this installer belongs to.

(Inherited from Installer)
Path Path Path Path

取得或設定要安裝的組件路徑。Gets or sets the path of the assembly to install.

Site Site Site Site

取得或設定 ComponentISiteGets or sets the ISite of the Component.

(Inherited from Component)
UseNewContext UseNewContext UseNewContext UseNewContext

取得或設定值,指出是否為組件的安裝建立新 InstallContext 物件。Gets or sets a value indicating whether to create a new InstallContext object for the assembly's installation.

方法

CheckIfInstallable(String) CheckIfInstallable(String) CheckIfInstallable(String) CheckIfInstallable(String)

檢查是否可以安裝指定的組件。Checks to see if the specified assembly can be installed.

Commit(IDictionary) Commit(IDictionary) Commit(IDictionary) Commit(IDictionary)

完成安裝異動。Completes the installation transaction.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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() Dispose() Dispose() Dispose()

釋放 Component 所使用的所有資源。Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
Install(IDictionary) Install(IDictionary) Install(IDictionary) Install(IDictionary)

執行安裝。Performs the installation.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnAfterInstall(IDictionary) OnAfterInstall(IDictionary) OnAfterInstall(IDictionary) OnAfterInstall(IDictionary)

引發 AfterInstall 事件。Raises the AfterInstall event.

(Inherited from Installer)
OnAfterRollback(IDictionary) OnAfterRollback(IDictionary) OnAfterRollback(IDictionary) OnAfterRollback(IDictionary)

引發 AfterRollback 事件。Raises the AfterRollback event.

(Inherited from Installer)
OnAfterUninstall(IDictionary) OnAfterUninstall(IDictionary) OnAfterUninstall(IDictionary) OnAfterUninstall(IDictionary)

引發 AfterUninstall 事件。Raises the AfterUninstall event.

(Inherited from Installer)
OnBeforeInstall(IDictionary) OnBeforeInstall(IDictionary) OnBeforeInstall(IDictionary) OnBeforeInstall(IDictionary)

引發 BeforeInstall 事件。Raises the BeforeInstall event.

(Inherited from Installer)
OnBeforeRollback(IDictionary) OnBeforeRollback(IDictionary) OnBeforeRollback(IDictionary) OnBeforeRollback(IDictionary)

引發 BeforeRollback 事件。Raises the BeforeRollback event.

(Inherited from Installer)
OnBeforeUninstall(IDictionary) OnBeforeUninstall(IDictionary) OnBeforeUninstall(IDictionary) OnBeforeUninstall(IDictionary)

引發 BeforeUninstall 事件。Raises the BeforeUninstall event.

(Inherited from Installer)
OnCommitted(IDictionary) OnCommitted(IDictionary) OnCommitted(IDictionary) OnCommitted(IDictionary)

引發 Committed 事件。Raises the Committed event.

(Inherited from Installer)
OnCommitting(IDictionary) OnCommitting(IDictionary) OnCommitting(IDictionary) OnCommitting(IDictionary)

引發 Committing 事件。Raises the Committing event.

(Inherited from Installer)
Rollback(IDictionary) Rollback(IDictionary) Rollback(IDictionary) Rollback(IDictionary)

將電腦還原至安裝之前的狀態。Restores the computer to the state it was in before the installation.

ToString() ToString() ToString() ToString()

傳回任何包含 Component 名稱的 StringReturns a String containing the name of the Component, if any. 不應覆寫此方法。This method should not be overridden.

(Inherited from Component)
Uninstall(IDictionary) Uninstall(IDictionary) Uninstall(IDictionary) Uninstall(IDictionary)

移除安裝。Removes an installation.

事件

AfterInstall AfterInstall AfterInstall AfterInstall

發生於 Install(IDictionary) 屬性中的所有安裝程式的 Installers 方法都已經執行之後。Occurs after the Install(IDictionary) methods of all the installers in the Installers property have run.

(Inherited from Installer)
AfterRollback AfterRollback AfterRollback AfterRollback

發生於 Installers 屬性中所有安裝程式的安裝都復原之後。Occurs after the installations of all the installers in the Installers property are rolled back.

(Inherited from Installer)
AfterUninstall AfterUninstall AfterUninstall AfterUninstall

發生於 Installers 屬性中的所有安裝程式執行其解除安裝作業之後。Occurs after all the installers in the Installers property perform their uninstallation operations.

(Inherited from Installer)
BeforeInstall BeforeInstall BeforeInstall BeforeInstall

發生於安裝程式集合中的每個安裝程式的 Install(IDictionary) 方法執行之前。Occurs before the Install(IDictionary) method of each installer in the installer collection has run.

(Inherited from Installer)
BeforeRollback BeforeRollback BeforeRollback BeforeRollback

發生於 Installers 屬性中的安裝程式復原之前。Occurs before the installers in the Installers property are rolled back.

(Inherited from Installer)
BeforeUninstall BeforeUninstall BeforeUninstall BeforeUninstall

發生於 Installers 屬性中的安裝程式執行其解除安裝作業之前。Occurs before the installers in the Installers property perform their uninstall operations.

(Inherited from Installer)
Committed Committed Committed Committed

發生於 Installers 屬性中的所有安裝程式都認可其安裝之後。Occurs after all the installers in the Installers property have committed their installations.

(Inherited from Installer)
Committing Committing Committing Committing

發生於 Installers 屬性中的安裝程式認可其安裝之前。Occurs before the installers in the Installers property commit their installations.

(Inherited from Installer)
Disposed Disposed Disposed Disposed

當此元件由 Dispose() 方法的呼叫處置時發生。Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

適用於