AssemblyInstaller.Commit(IDictionary) Método
Definição
Conclui a transação de instalação.Completes the installation transaction.
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)
Parâmetros
- savedState
- IDictionary
Um IDictionary que contém o estado do computador após todos os instaladores na coleção terem sido executados.An IDictionary that contains the state of the computer after all the installers in the installer collection have run.
Exceções
O parâmetro savedState é null.The savedState parameter is null.
- ou --or- O IDictionary de estado salvo pode estar corrompido.The saved-state IDictionary might have been corrupted.
- ou --or- Não foi possível encontrar um arquivo.A file could not be found.
Ocorreu um erro no manipulador de eventos Committing de um dos instaladores na coleção.An error occurred in the Committing event handler of one of the installers in the collection.
- ou --or- Ocorreu um erro no manipulador de eventos Committed de um dos instaladores na coleção.An error occurred in the Committed event handler of one of the installers in the collection.
- ou --or- Ocorreu uma exceção durante a fase Commit(IDictionary) da instalação.An exception occurred during the Commit(IDictionary) phase of the installation. A exceção é ignorada e a instalação continua.The exception is ignored and the installation continues. No entanto, o aplicativo pode não funcionar corretamente após a instalação ser concluída.However, the application might not function correctly after installation completes.
- ou --or- Os tipos de instalador não foram encontrados em um dos assemblies.Installer types were not found in one of the assemblies.
- ou --or- Não foi possível criar uma instância de um dos tipos de instalador.An instance of one of the installer types could not be created.
Ocorreu uma exceção durante a fase Commit(IDictionary) da instalação.An exception occurred during the Commit(IDictionary) phase of the installation. A exceção é ignorada e a instalação continua.The exception is ignored and the installation continues. No entanto, o aplicativo pode não funcionar corretamente após a instalação ser concluída.However, the application might not function correctly after installation completes.
Exemplos
O exemplo a seguir demonstra o AssemblyInstaller Construtor e Install os Commit métodos e da AssemblyInstaller classe.The following example demonstrates the AssemblyInstaller constructor and the Install and Commit methods of the AssemblyInstaller class.
Uma AssemblyInstaller classe é criada invocando o AssemblyInstaller Construtor.An AssemblyInstaller class is created by invoking the AssemblyInstaller constructor. As propriedades desse objeto são definidas e os Install métodos e Commit são chamados para instalar o MyAssembly_Install.exe assembly.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
Comentários
Esse método será chamado somente se os Install métodos de todos os instaladores na instância InstallerCollection forem bem-sucedidos.This method is called only if the Install methods of all the installers in this instance's InstallerCollection succeed. Esse método chama o Commit método de cada instalador na coleção.This method then calls the Commit method of each installer in the collection.
Armazene todas as informações de que você pode precisar para fazer uma operação de desinstalação correta no estado salvo IDictionary , que é passado para o Uninstall método.Store any information that you might need to do a correct uninstall operation in the saved-state IDictionary, which is passed to the Uninstall method.