Share via


InstallException Constructeurs

Définition

Initialise une nouvelle instance de la classe InstallException.

Surcharges

InstallException()

Initialise une nouvelle instance de la classe InstallException.

InstallException(String)

Initialise une nouvelle instance de la classe InstallException et spécifie le message à afficher à l'intention de l'utilisateur.

InstallException(SerializationInfo, StreamingContext)

Initialise une nouvelle instance de la classe InstallException avec des données sérialisées.

InstallException(String, Exception)

Initialise une nouvelle instance de la classe InstallException et spécifie le message à afficher à l'utilisateur, ainsi qu'une référence à l'exception interne ayant provoqué cette exception.

InstallException()

Initialise une nouvelle instance de la classe InstallException.

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

Exemples

L’exemple suivant illustre le InstallException constructeur. Il fait partie de l’exemple de la InstallException classe .

Dans cet exemple, Installutil.exe appelle la Commit méthode . Le code dans Commit suppose qu’un fichier nommé FileDoesNotExist.txt existe avant que l’installation de l’assembly puisse être validée. Si le fichier FileDoesNotExist.txt n’existe pas, Commit déclenche un InstallException.

Notes

Cet exemple montre comment utiliser l’une des versions surchargées du InstallException constructeur. Pour obtenir d’autres exemples qui peuvent être disponibles, consultez les rubriques de surcharge individuelles.

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

S’applique à

InstallException(String)

Initialise une nouvelle instance de la classe InstallException et spécifie le message à afficher à l'intention de l'utilisateur.

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)

Paramètres

message
String

Message à afficher à l'intention de l'utilisateur.

Exemples

L’exemple suivant illustre le InstallException constructeur. Il fait partie de l’exemple de la InstallException classe .

Dans cet exemple, Installutil.exe appelle la Uninstall méthode . La désinstallation se produit uniquement si un fichier nommé FileDoesNotExist.txt existe. Sinon, il déclenche un InstallException.

Notes

Cet exemple montre comment utiliser l’une des versions surchargées du InstallException constructeur. Pour obtenir d’autres exemples qui peuvent être disponibles, consultez les rubriques de surcharge individuelles.

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

S’applique à

InstallException(SerializationInfo, StreamingContext)

Initialise une nouvelle instance de la classe InstallException avec des données sérialisées.

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)

Paramètres

info
SerializationInfo

SerializationInfo qui contient les données d'objet sérialisées concernant l'exception levée.

context
StreamingContext

StreamingContext qui contient des informations contextuelles relatives à la source ou à la destination.

S’applique à

InstallException(String, Exception)

Initialise une nouvelle instance de la classe InstallException et spécifie le message à afficher à l'utilisateur, ainsi qu'une référence à l'exception interne ayant provoqué cette exception.

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)

Paramètres

message
String

Message à afficher à l'intention de l'utilisateur.

innerException
Exception

Exception ayant provoqué l'exception actuelle. Si le paramètre innerException n'est pas null, l'exception actuelle est levée dans un bloc catch qui gère l'exception interne.

S’applique à