AssemblyInstaller 類別

定義

載入組件,並且執行組件中的所有安裝程式。

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 建立 。 會設定此物件的屬性, Install 並呼叫 和 Commit 方法來安裝 MyAssembly.exe 元件。

#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

建構函式

AssemblyInstaller()

初始化 AssemblyInstaller 類別的新執行個體。

AssemblyInstaller(Assembly, String[])

初始化 AssemblyInstaller 類別的新執行個體,並且指定當建立新 InstallContext 物件時要安裝的組件和要使用的命令列。

AssemblyInstaller(String, String[])

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

屬性

Assembly

取得或設定要安裝的組件。

CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
CommandLine

取得或設定當為組件的安裝建立新 InstallContext 物件時要使用的命令列。

Container

取得包含 IContainerComponent

(繼承來源 Component)
Context

取得或設定有關目前安裝的資訊。

(繼承來源 Installer)
DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
HelpText

取得安裝程式集合中所有安裝程式的說明文字。

Installers

取得這個安裝程式包含的安裝程式集合。

(繼承來源 Installer)
Parent

取得或設定安裝程式,含有這個安裝程式所屬的集合。

(繼承來源 Installer)
Path

取得或設定要安裝的組件路徑。

Site

取得或設定 ComponentISite

(繼承來源 Component)
UseNewContext

取得或設定值,指出是否為組件的安裝建立新 InstallContext 物件。

方法

CheckIfInstallable(String)

檢查是否可以安裝指定的組件。

Commit(IDictionary)

完成安裝異動。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
Install(IDictionary)

執行安裝。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
OnAfterInstall(IDictionary)

引發 AfterInstall 事件。

(繼承來源 Installer)
OnAfterRollback(IDictionary)

引發 AfterRollback 事件。

(繼承來源 Installer)
OnAfterUninstall(IDictionary)

引發 AfterUninstall 事件。

(繼承來源 Installer)
OnBeforeInstall(IDictionary)

引發 BeforeInstall 事件。

(繼承來源 Installer)
OnBeforeRollback(IDictionary)

引發 BeforeRollback 事件。

(繼承來源 Installer)
OnBeforeUninstall(IDictionary)

引發 BeforeUninstall 事件。

(繼承來源 Installer)
OnCommitted(IDictionary)

引發 Committed 事件。

(繼承來源 Installer)
OnCommitting(IDictionary)

引發 Committing 事件。

(繼承來源 Installer)
Rollback(IDictionary)

將電腦還原至安裝之前的狀態。

ToString()

傳回任何包含 Component 名稱的 String。 不應覆寫此方法。

(繼承來源 Component)
Uninstall(IDictionary)

移除安裝。

事件

AfterInstall

發生於 Installers 屬性中所有安裝程式的 Install(IDictionary) 方法都執行之後。

(繼承來源 Installer)
AfterRollback

發生於 Installers 屬性中所有安裝程式的安裝都復原之後。

(繼承來源 Installer)
AfterUninstall

發生於 Installers 屬性中的所有安裝程式執行其解除安裝作業之後。

(繼承來源 Installer)
BeforeInstall

發生於安裝程式集合中每個安裝程式的 Install(IDictionary) 方法執行之前。

(繼承來源 Installer)
BeforeRollback

發生於 Installers 屬性中的安裝程式復原之前。

(繼承來源 Installer)
BeforeUninstall

發生於 Installers 屬性中的安裝程式執行其解除安裝作業之前。

(繼承來源 Installer)
Committed

發生於 Installers 屬性中的所有安裝程式都認可其安裝之後。

(繼承來源 Installer)
Committing

發生於 Installers 屬性中的安裝程式認可其安裝之前。

(繼承來源 Installer)
Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)

適用於