AssemblyInstaller.Install(IDictionary) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Provede instalaci.
public:
override void Install(System::Collections::IDictionary ^ savedState);
public override void Install(System.Collections.IDictionary savedState);
override this.Install : System.Collections.IDictionary -> unit
Public Overrides Sub Install (savedState As IDictionary)
Parametry
- savedState
- IDictionary
Slouží IDictionary k ukládání informací potřebných k provedení operace potvrzení, vrácení zpět nebo odinstalace.
Výjimky
V obslužné rutině události některého z instalačních programů v kolekci došlo k BeforeInstall výjimce.
nebo
V obslužné rutině události některého z instalačních programů v kolekci došlo k AfterInstall výjimce.
nebo
V jednom ze sestavení nebyly nalezeny typy instalačního programu.
nebo
Instanci jednoho z typů instalačního programu nelze vytvořit.
Příklady
Následující příklad ukazuje AssemblyInstaller konstruktor a Install metody CommitAssemblyInstaller třídy.
Objekt AssemblyInstaller třídy je vytvořen vyvoláním konstruktoru AssemblyInstaller . Vlastnosti tohoto objektu jsou nastaveny a Install a Commit metody jsou volány k instalaci 'MyAssembly_Install.exe' sestavení '.
#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
Poznámky
Tato metoda volá metodu Install každého instalačního programu obsaženého ve Installers vlastnosti této instance. Objekt IDictionary určený parametrem savedState se aktualizuje tak, aby odrážel stav instalace po spuštění obsažených instalačních programů. Pokud jsou všechny Install metody úspěšné, volá se Commit metoda.
Rollback V opačném případě je volána metoda.
Poznámky pro volající
savedState Zadaný IDictionary parametr by měl být při předání Install(IDictionary) metodě prázdný.