AssemblyInstaller 构造函数

定义

初始化 AssemblyInstaller 类的新实例。

重载

AssemblyInstaller()

初始化 AssemblyInstaller 类的新实例。

AssemblyInstaller(Assembly, String[])

初始化 AssemblyInstaller 类的新实例,并且指定要安装的程序集以及在创建新的 InstallContext 对象时要使用的命令行。

AssemblyInstaller(String, String[])

初始化 AssemblyInstaller 类的新实例,并且指定在为程序集安装创建新的 InstallContext 对象时要安装的程序集的文件名和要使用的命令行。

AssemblyInstaller()

初始化 AssemblyInstaller 类的新实例。

public:
 AssemblyInstaller();
public AssemblyInstaller ();
Public Sub New ()

示例

下面的示例演示 类的 AssemblyInstaller 构造函数和 InstallCommit 方法 AssemblyInstaller

AssemblyInstaller通过调用 AssemblyInstaller 构造函数创建 。 设置此对象的属性, Install 并调用 和 Commit 方法来安装 MyAssembly_Install.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;
void main()
{
   IDictionary^ mySavedState = gcnew Hashtable;
   Console::WriteLine( "" );
   try
   {
      // Set the commandline argument array for 'logfile'.
      array<String^>^myString = {"/logFile=example.log"};
      
      // Create an Object* of the 'AssemblyInstaller' class.
      AssemblyInstaller^ myAssemblyInstaller = gcnew AssemblyInstaller;

      // Set the properties to install the required assembly.
      myAssemblyInstaller->Path = "MyAssembly_Install.exe";
      myAssemblyInstaller->CommandLine = myString;
      myAssemblyInstaller->UseNewContext = true;
      
      // Clear the 'IDictionary' Object*.
      mySavedState->Clear();
      
      // Install the 'MyAssembly_Install' assembly.
      myAssemblyInstaller->Install( mySavedState );
      
      // Commit the 'MyAssembly_Install' assembly.
      myAssemblyInstaller->Commit( mySavedState );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e );
   }
}
using System;
using System.Configuration.Install;
using System.Collections;
using System.Collections.Specialized;

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

      Console.WriteLine( "" );

      try
      {
         // Set the commandline argument array for 'logfile'.
         string[] myString = new string[ 1 ];
         myString[ 0 ] = "/logFile=example.log";

         // Create an object of the 'AssemblyInstaller' class.
         AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();

         // Set the properties to install the required assembly.
         myAssemblyInstaller.Path = "MyAssembly_Install.exe";
         myAssemblyInstaller.CommandLine = myString;
         myAssemblyInstaller.UseNewContext = true;

         // Clear the 'IDictionary' object.
         mySavedState.Clear();

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

         // Commit the 'MyAssembly_Install' assembly.
         myAssemblyInstaller.Commit( mySavedState );
      }
      catch( Exception )
      {
      }
   }
}
Imports System.Configuration.Install
Imports System.Collections
Imports System.Collections.Specialized

Class MyInstallClass
   
   Shared Sub Main()
      Dim mySavedState = New Hashtable()
      
      Console.WriteLine("")
      

      Try
         ' Set the commandline argument array for 'logfile'.
         Dim myString(0) As String
         myString(0) = "/logFile=example.log"
         ' Create an object of the 'AssemblyInstaller' class.
         Dim myAssemblyInstaller As New AssemblyInstaller()
         ' Set the properties to install the required assembly.
         myAssemblyInstaller.Path = "MyAssembly_Install.exe"
         myAssemblyInstaller.CommandLine = myString
         myAssemblyInstaller.UseNewContext = True
         
         ' Clear the 'IDictionary' object.
         mySavedState.Clear()
         
         ' Install the 'MyAssembly_Install' assembly.
         myAssemblyInstaller.Install(mySavedState)
         
         ' Commit the 'MyAssembly_Install' assembly.
         myAssemblyInstaller.Commit(mySavedState)
      Catch
      End Try

   End Sub
End Class

适用于

AssemblyInstaller(Assembly, String[])

初始化 AssemblyInstaller 类的新实例,并且指定要安装的程序集以及在创建新的 InstallContext 对象时要使用的命令行。

public:
 AssemblyInstaller(System::Reflection::Assembly ^ assembly, cli::array <System::String ^> ^ commandLine);
public AssemblyInstaller (System.Reflection.Assembly assembly, string[] commandLine);
new System.Configuration.Install.AssemblyInstaller : System.Reflection.Assembly * string[] -> System.Configuration.Install.AssemblyInstaller
Public Sub New (assembly As Assembly, commandLine As String())

参数

assembly
Assembly

要安装的 Assembly

commandLine
String[]

在为程序集安装创建新的 InstallContext 对象时要使用的命令行。 可以为 null 值。

另请参阅

适用于

AssemblyInstaller(String, String[])

初始化 AssemblyInstaller 类的新实例,并且指定在为程序集安装创建新的 InstallContext 对象时要安装的程序集的文件名和要使用的命令行。

public:
 AssemblyInstaller(System::String ^ filename, cli::array <System::String ^> ^ commandLine);
public:
 AssemblyInstaller(System::String ^ fileName, cli::array <System::String ^> ^ commandLine);
public AssemblyInstaller (string filename, string[] commandLine);
public AssemblyInstaller (string fileName, string[] commandLine);
new System.Configuration.Install.AssemblyInstaller : string * string[] -> System.Configuration.Install.AssemblyInstaller
new System.Configuration.Install.AssemblyInstaller : string * string[] -> System.Configuration.Install.AssemblyInstaller
Public Sub New (filename As String, commandLine As String())
Public Sub New (fileName As String, commandLine As String())

参数

filenamefileName
String

要安装的程序集的文件名。

commandLine
String[]

在为程序集安装创建新的 InstallContext 对象时要使用的命令行。 可以为 null 值。

示例

在下面的示例中, AssemblyInstaller 通过使用要安装的程序集和命令行参数数组作为参数调用 AssemblyInstaller 构造函数来创建 。

array<String^>^myStringArray = {"/logFile=example.log"};
String^ myString = "MyAssembly_Uninstall.exe";

// Create an object of the 'AssemblyInstaller' class.
AssemblyInstaller^ myAssemblyInstaller =
   gcnew AssemblyInstaller( myString,myStringArray );
string[] myStringArray = new string[ 1 ];
string myString;

// Set the commandline argument array for 'logfile'.
myStringArray[ 0 ] = "/logFile=example.log";

// Set the name of the assembly to install.
myString = "MyAssembly_Uninstall.exe";

// Create an object of the 'AssemblyInstaller' class.
AssemblyInstaller myAssemblyInstaller = new
         AssemblyInstaller( myString , myStringArray );
Dim myStringArray(0) As String
Dim myString As String


' Set the commandline argument array for 'logfile'.
myStringArray(0) = "/logFile=example.log"

' Set the name of the assembly to install.
myString = "MyAssembly_Uninstall.exe"

' Create an object of the 'AssemblyInstaller' class.
Dim myAssemblyInstaller As New AssemblyInstaller(myString, myStringArray)

另请参阅

适用于