AssemblyInstaller 建構函式

定義

初始化 AssemblyInstaller 類別的新執行個體。Initializes a new instance of the AssemblyInstaller 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.

AssemblyInstaller()

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

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

範例

下列範例示範的是AssemblyInstaller方法, Install以及AssemblyInstaller類別Commit的和方法。The following example demonstrates the AssemblyInstaller constructor and the Install and Commit methods of the AssemblyInstaller class.

AssemblyInstaller藉由叫用此AssemblyInstaller函式來建立。An AssemblyInstaller is created by invoking the AssemblyInstaller constructor. 已設定這個物件的屬性,並Install呼叫和Commit方法來安裝MyAssembly_Install.exe元件。The properties of this object are set and the Install and Commit methods are called to install the MyAssembly_Install.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;
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 物件時要安裝的組件和要使用的命令列。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.

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

參數

assembly
Assembly

要安裝的 AssemblyThe Assembly to install.

commandLine
String[]

當為組件的安裝建立新 InstallContext 物件時要使用的命令列。The command line to use when creating a new InstallContext object for the assembly's installation. 可以是 null 值。Can be a null value.

另請參閱

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.

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

參數

filename
String

要安裝的組件檔案名稱。The file name of the assembly to install.

commandLine
String[]

當為組件的安裝建立新 InstallContext 物件時要使用的命令列。The command line to use when creating a new InstallContext object for the assembly's installation. 可以是 null 值。Can be a null value.

範例

在下列範例中,會AssemblyInstaller藉由AssemblyInstaller叫用具有要安裝之元件的函式和命令列引數陣列做為參數來建立。In the following example, an AssemblyInstaller is created by invoking the AssemblyInstaller constructor with the assembly to install and the command line argument array as parameters.

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)

另請參閱

適用於