InstallException Konstruktory

Definicja

Inicjuje nowe wystąpienie klasy InstallException.

Przeciążenia

InstallException()

Inicjuje nowe wystąpienie klasy InstallException.

InstallException(String)

Inicjuje InstallException nowe wystąpienie klasy i określa komunikat do wyświetlenia użytkownikowi.

InstallException(SerializationInfo, StreamingContext)

Inicjuje nowe wystąpienie klasy InstallException z zserializowanymi danymi.

InstallException(String, Exception)

Inicjuje InstallException nowe wystąpienie klasy i określa komunikat, który ma być wyświetlany użytkownikowi, oraz odwołanie do wewnętrznego wyjątku, który jest przyczyną tego wyjątku.

InstallException()

Inicjuje nowe wystąpienie klasy InstallException.

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

Przykłady

W poniższym przykładzie InstallException pokazano konstruktor. Jest to część przykładu InstallException klasy .

W tym przykładzie Installutil.exe wywołuje metodę Commit . Kod zakłada Commit , że plik o nazwie FileDoesNotExist.txt istnieje przed instalacją zestawu może zostać zatwierdzony. Jeśli plik FileDoesNotExist.txt nie istnieje, Commit zgłasza element InstallException.

Uwaga

W tym przykładzie pokazano, jak używać jednej z przeciążonych wersji konstruktora InstallException . Inne przykłady, które mogą być dostępne, można znaleźć w poszczególnych tematach przeciążenia.

virtual void Commit( IDictionary^ savedState ) override
{
   Installer::Commit( savedState );
   Console::WriteLine( "Commit ..." );
   
   // Throw an error if a particular file doesn't exist.
   if (  !File::Exists( "FileDoesNotExist.txt" ) )
         throw gcnew InstallException;

   
   // Perform the final installation if the file exists.
}
public override void Commit(IDictionary savedState)
{
   base.Commit(savedState);
   Console.WriteLine("Commit ...");
   // Throw an error if a particular file doesn't exist.
   if(!File.Exists("FileDoesNotExist.txt"))
      throw new InstallException();
   // Perform the final installation if the file exists.
}
Public Overrides Sub Commit(savedState As IDictionary)
   MyBase.Commit(savedState)
   Console.WriteLine("Commit ...")
   ' Throw an error if a particular file doesn't exist.
   If Not File.Exists("FileDoesNotExist.txt") Then
      Throw New InstallException()
   End If
   ' Perform the final installation if the file exists.
End Sub

Dotyczy

InstallException(String)

Inicjuje InstallException nowe wystąpienie klasy i określa komunikat do wyświetlenia użytkownikowi.

public:
 InstallException(System::String ^ message);
public InstallException (string message);
new System.Configuration.Install.InstallException : string -> System.Configuration.Install.InstallException
Public Sub New (message As String)

Parametry

message
String

Komunikat do wyświetlenia użytkownikowi.

Przykłady

W poniższym przykładzie InstallException pokazano konstruktor. Jest to część przykładu InstallException klasy .

W tym przykładzie Installutil.exe wywołuje metodę Uninstall . Dezinstalacja będzie miała miejsce tylko wtedy, gdy istnieje plik o nazwie FileDoesNotExist.txt . W przeciwnym razie zgłasza błąd InstallException.

Uwaga

W tym przykładzie pokazano, jak używać jednej z przeciążonych wersji konstruktora InstallException . Inne przykłady, które mogą być dostępne, można znaleźć w poszczególnych tematach przeciążenia.

virtual void Uninstall( IDictionary^ savedState ) override
{
   Installer::Uninstall( savedState );
   Console::WriteLine( "UnInstall ..." );
   
   // Throw an error if a particular file doesn't exist.
   if (  !File::Exists( "FileDoesNotExist.txt" ) )
         throw gcnew InstallException( "The file 'FileDoesNotExist'  does not exist" );

   
   // Perform the uninstall activites if the file exists.
}
public override void Uninstall(IDictionary savedState)
{
   base.Uninstall(savedState);
   Console.WriteLine("UnInstall ...");
   // Throw an error if a particular file doesn't exist.
   if(!File.Exists("FileDoesNotExist.txt"))
      throw new InstallException("The file 'FileDoesNotExist'" +
         " does not exist");
   // Perform the uninstall activites if the file exists.
}
Public Overrides Sub Uninstall(savedState As IDictionary)
   MyBase.Uninstall(savedState)
   Console.WriteLine("UnInstall ...")
   ' Throw an error if a particular file doesn't exist.
   If Not File.Exists("FileDoesNotExist.txt") Then
      Throw New InstallException("The file 'FileDoesNotExist'" + " does not exist")
   End If
   ' Perform the uninstall activites if the file exists.
End Sub

Dotyczy

InstallException(SerializationInfo, StreamingContext)

Inicjuje nowe wystąpienie klasy InstallException z zserializowanymi danymi.

protected:
 InstallException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected InstallException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Configuration.Install.InstallException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Configuration.Install.InstallException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parametry

info
SerializationInfo

Obiekt SerializationInfo zawierający dane zserializowanego obiektu dotyczące zgłaszanego wyjątku.

context
StreamingContext

Obiekt StreamingContext zawierający informacje kontekstowe dotyczące źródła lub miejsca docelowego.

Dotyczy

InstallException(String, Exception)

Inicjuje InstallException nowe wystąpienie klasy i określa komunikat, który ma być wyświetlany użytkownikowi, oraz odwołanie do wewnętrznego wyjątku, który jest przyczyną tego wyjątku.

public:
 InstallException(System::String ^ message, Exception ^ innerException);
public InstallException (string message, Exception innerException);
new System.Configuration.Install.InstallException : string * Exception -> System.Configuration.Install.InstallException
Public Sub New (message As String, innerException As Exception)

Parametry

message
String

Komunikat do wyświetlenia użytkownikowi.

innerException
Exception

Wyjątek będący przyczyną bieżącego wyjątku. innerException Jeśli parametr nie nulljest , bieżący wyjątek jest zgłaszany w catch bloku, który obsługuje wyjątek wewnętrzny.

Dotyczy