AssemblyInstaller 类

加载一个程序集,并运行其中的所有安装程序。

**命名空间:**System.Configuration.Install
**程序集:**System.Configuration.Install(在 system.configuration.install.dll 中)

语法

声明
Public Class AssemblyInstaller
    Inherits Installer
用法
Dim instance As AssemblyInstaller
public class AssemblyInstaller : Installer
public ref class AssemblyInstaller : public Installer
public class AssemblyInstaller extends Installer
public class AssemblyInstaller extends Installer

示例

在下面的示例中,通过调用 AssemblyInstaller 构造函数,创建了 AssemblyInstaller。设置该对象的属性,并通过调用 InstallCommit 方法安装 MyAssembly.exe 程序集。

Imports System
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 'Main
End Class 'AssemblyInstaller_Example
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 );
      }
   }
}
#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 );
   }
}
import System.*;
import System.Configuration.Install.*;
import System.Collections.*;
import System.Collections.Specialized.*;

class AssemblyInstallerExample
{
    public static void main(String[] args)
    {
        IDictionary mySavedState = new Hashtable();

        Console.WriteLine("");
        try {
            // Set the commandline argument array for 'logfile'.
            String commandLineOptions[] = 
                new String[] { "/LogFile=example.log" };

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

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

            // Commit the 'MyAssembly' assembly.
            myAssemblyInstaller.Commit(mySavedState);
        }
        catch (ArgumentException exp) {
        }
        catch (System.Exception e) {
            Console.WriteLine(e.get_Message());
        }
    } //main
} //AssemblyInstallerExample

继承层次结构

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Configuration.Install.Installer
        System.Configuration.Install.AssemblyInstaller

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

AssemblyInstaller 成员
System.Configuration.Install 命名空间