Redigera

Dela via


InstallException Constructors

Definition

Initializes a new instance of the InstallException class.

Overloads

InstallException()

Initializes a new instance of the InstallException class.

InstallException(String)

Initializes a new instance of the InstallException class, and specifies the message to display to the user.

InstallException(SerializationInfo, StreamingContext)

Initializes a new instance of the InstallException class with serialized data.

InstallException(String, Exception)

Initializes a new instance of the InstallException class, and specifies the message to display to the user, and a reference to the inner exception that is the cause of this exception.

InstallException()

Initializes a new instance of the InstallException class.

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

Examples

The following example demonstrates the InstallException constructor. It is a part of the example of the InstallException class.

In this example, Installutil.exe calls the Commit method. The code in Commit presumes that a file named FileDoesNotExist.txt exists before the installation of the assembly can be committed. If the file FileDoesNotExist.txt does not exist, Commit raises an InstallException.

Note

This example shows how to use one of the overloaded versions of the InstallException constructor. For other examples that might be available, see the individual overload topics.

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

Applies to

InstallException(String)

Initializes a new instance of the InstallException class, and specifies the message to display to the user.

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)

Parameters

message
String

The message to display to the user.

Examples

The following example demonstrates the InstallException constructor. It is a part of the example of the InstallException class.

In this example, Installutil.exe calls the Uninstall method. Uninstallation will only happen if a file named FileDoesNotExist.txt exists. Otherwise it raises an InstallException.

Note

This example shows how to use one of the overloaded versions of the InstallException constructor. For other examples that might be available, see the individual overload topics.

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

Applies to

InstallException(SerializationInfo, StreamingContext)

Initializes a new instance of the InstallException class with serialized data.

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)

Parameters

info
SerializationInfo

The SerializationInfo that holds the serialized object data about the exception being thrown.

context
StreamingContext

The StreamingContext that contains contextual information about the source or destination.

Applies to

InstallException(String, Exception)

Initializes a new instance of the InstallException class, and specifies the message to display to the user, and a reference to the inner exception that is the cause of this 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)

Parameters

message
String

The message to display to the user.

innerException
Exception

The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

Applies to