AssemblyInstaller.Commit(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í.
Dokončí instalační transakci.
public:
override void Commit(System::Collections::IDictionary ^ savedState);
public override void Commit(System.Collections.IDictionary savedState);
override this.Commit : System.Collections.IDictionary -> unit
Public Overrides Sub Commit (savedState As IDictionary)
Parametry
- savedState
- IDictionary
Stav IDictionary počítače obsahuje po spuštění všech instalačních programů v kolekci instalačních programů.
Výjimky
Parametr savedState je null.
nebo
Uložený stav IDictionary byl pravděpodobně poškozen.
nebo
Soubor nebyl nalezen.
V obslužné rutině události některého z instalačních programů v kolekci došlo k Committing chybě.
nebo
V obslužné rutině události některého z instalačních programů v kolekci došlo k Committed chybě.
nebo
Během fáze instalace došlo k Commit(IDictionary) výjimce. Výjimka se ignoruje a instalace bude pokračovat. Po dokončení instalace ale aplikace nemusí správně fungovat.
nebo
V jednom ze sestavení nebyly nalezeny typy instalačního programu.
nebo
Instanci jednoho z typů instalačního programu nelze vytvořit.
Během fáze instalace došlo k Commit(IDictionary) výjimce. Výjimka se ignoruje a instalace bude pokračovat. Po dokončení instalace ale aplikace nemusí správně fungovat.
Příklady
Následující příklad ukazuje AssemblyInstaller konstruktor a Install metody CommitAssemblyInstaller třídy.
Třída AssemblyInstaller je vytvořena 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 je volána pouze v případě, že Install metody všech instalačních programů v této instanci InstallerCollection jsou úspěšné. Tato metoda pak volá metodu Commit každého instalačního programu v kolekci.
Uložte všechny informace, které možná budete muset provést správnou operaci odinstalace v uloženém stavu IDictionary, který se předá Uninstall metodě.