Freigeben über


AssemblyInstaller-Konstruktor ()

Initialisiert eine neue Instanz der AssemblyInstaller-Klasse.

Namespace: System.Configuration.Install
Assembly: System.Configuration.Install (in system.configuration.install.dll)

Syntax

'Declaration
Public Sub New
'Usage
Dim instance As New AssemblyInstaller
public AssemblyInstaller ()
public:
AssemblyInstaller ()
public AssemblyInstaller ()
public function AssemblyInstaller ()

Beispiel

Das folgende Beispiel veranschaulicht den AssemblyInstaller-Konstruktor sowie die Install-Methode und die Commit-Methode der AssemblyInstaller-Klasse.

Ein AssemblyInstaller wird durch einen Aufruf des AssemblyInstaller-Konstruktors erstellt. Die Eigenschaften dieses Objekts werden festgelegt, und die Install-Methode und die Commit-Methode werden aufgerufen, um die MyAssembly_Install.exe-Assembly zu installieren.

Imports System
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 'Main
End Class 'MyInstallClass 
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 )
      {
      }


   }
}
#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 );
   }
}
import System.*;
import System.Configuration.Install.*;
import System.Collections.*;
import System.Collections.Specialized.*;

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

        Console.WriteLine("");
        try {
            // Set the commandline argument array for 'logfile'.
            String myString[] = new String[1];
            myString.set_Item(0, "/logFile=example.log");

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

            // Set the properties to install the required assembly.
            myAssemblyInstaller.set_Path("MyAssembly_Install.exe");
            myAssemblyInstaller.set_CommandLine(myString);
            myAssemblyInstaller.set_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 (System.Exception exp) {
        }
    } //main
} //MyInstallClass

.NET Framework-Sicherheit

  • Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter .

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

AssemblyInstaller-Klasse
AssemblyInstaller-Member
System.Configuration.Install-Namespace