AssemblyInstaller 类

定义

加载一个程序集,并运行其中的所有安装程序。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()

初始化 AssemblyInstaller 类的新实例。Initializes a new instance of the AssemblyInstaller class.

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 类的新实例,并且指定在为程序集安装创建新的 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

获取或设置要安装的程序集。Gets or sets the assembly to install.

CanRaiseEvents

获取一个指示组件是否可以引发事件的值。Gets a value indicating whether the component can raise an event.

(继承自 Component)
CommandLine

获取或设置在为程序集安装创建新的 InstallContext 对象时要使用的命令行。Gets or sets the command line to use when creating a new InstallContext object for the assembly's installation.

Container

获取 IContainer,它包含 ComponentGets the IContainer that contains the Component.

(继承自 Component)
Context

获取或设置关于当前安装的信息。Gets or sets information about the current installation.

(继承自 Installer)
DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

(继承自 Component)
Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

(继承自 Component)
HelpText

获取安装程序集合中所有安装程序的帮助文字。Gets the help text for all the installers in the installer collection.

Installers

获取该安装程序包含的安装程序的集合。Gets the collection of installers that this installer contains.

(继承自 Installer)
Parent

获取或设置包含该安装程序所属的集合的安装程序。Gets or sets the installer containing the collection that this installer belongs to.

(继承自 Installer)
Path

获取或设置要安装的程序集的路径。Gets or sets the path of the assembly to install.

Site

获取或设置 ComponentISiteGets or sets the ISite of the Component.

(继承自 Component)
UseNewContext

获取或设置一个值,该值指示是否为程序集安装创建新的 InstallContext 对象。Gets or sets a value indicating whether to create a new InstallContext object for the assembly's installation.

方法

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.

(继承自 MarshalByRefObject)
Dispose()

释放由 Component 使用的所有资源。Releases all resources used by the Component.

(继承自 Component)
Dispose(Boolean)

释放由 Component 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(继承自 Component)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

(继承自 Component)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
Install(IDictionary)

执行安装。Performs the installation.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
OnAfterInstall(IDictionary)

引发 AfterInstall 事件。Raises the AfterInstall event.

(继承自 Installer)
OnAfterRollback(IDictionary)

引发 AfterRollback 事件。Raises the AfterRollback event.

(继承自 Installer)
OnAfterUninstall(IDictionary)

引发 AfterUninstall 事件。Raises the AfterUninstall event.

(继承自 Installer)
OnBeforeInstall(IDictionary)

引发 BeforeInstall 事件。Raises the BeforeInstall event.

(继承自 Installer)
OnBeforeRollback(IDictionary)

引发 BeforeRollback 事件。Raises the BeforeRollback event.

(继承自 Installer)
OnBeforeUninstall(IDictionary)

引发 BeforeUninstall 事件。Raises the BeforeUninstall event.

(继承自 Installer)
OnCommitted(IDictionary)

引发 Committed 事件。Raises the Committed event.

(继承自 Installer)
OnCommitting(IDictionary)

引发 Committing 事件。Raises the Committing event.

(继承自 Installer)
Rollback(IDictionary)

将计算机还原为安装前的状态。Restores the computer to the state it was in before the installation.

ToString()

返回包含 Component 的名称的 String(如果有)。Returns a String containing the name of the Component, if any. 不应重写此方法。This method should not be overridden.

(继承自 Component)
Uninstall(IDictionary)

移除安装。Removes an installation.

事件

AfterInstall

Install(IDictionary) 属性中的所有安装程序的 Installers 方法都运行后发生。Occurs after the Install(IDictionary) methods of all the installers in the Installers property have run.

(继承自 Installer)
AfterRollback

在回滚 Installers 属性中所有安装程序的安装后发生。Occurs after the installations of all the installers in the Installers property are rolled back.

(继承自 Installer)
AfterUninstall

Installers 属性中所有安装程序都执行它们的卸载操作后发生。Occurs after all the installers in the Installers property perform their uninstallation operations.

(继承自 Installer)
BeforeInstall

在安装程序集合中每个安装程序的 Install(IDictionary) 方法运行前发生。Occurs before the Install(IDictionary) method of each installer in the installer collection has run.

(继承自 Installer)
BeforeRollback

在回滚 Installers 属性中的安装程序前发生。Occurs before the installers in the Installers property are rolled back.

(继承自 Installer)
BeforeUninstall

Installers 属性中的安装程序执行它们的卸载操作前发生。Occurs before the installers in the Installers property perform their uninstall operations.

(继承自 Installer)
Committed

Installers 属性中的所有安装程序均提交它们的安装后发生。Occurs after all the installers in the Installers property have committed their installations.

(继承自 Installer)
Committing

Installers 属性中的安装程序提交它们的安装前发生。Occurs before the installers in the Installers property commit their installations.

(继承自 Installer)
Disposed

当通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

(继承自 Component)

适用于