InstallException InstallException InstallException InstallException Constructors

定义

重载

InstallException() InstallException() InstallException()

初始化 InstallException 类的新实例。Initializes a new instance of the InstallException class.

InstallException(String) InstallException(String) InstallException(String) InstallException(String)

初始化 InstallException 类的新实例,并指定要显示给用户的消息。Initializes a new instance of the InstallException class, and specifies the message to display to the user.

InstallException(SerializationInfo, StreamingContext) InstallException(SerializationInfo, StreamingContext) InstallException(SerializationInfo, StreamingContext) InstallException(SerializationInfo, StreamingContext)

用序列化数据初始化 InstallException 类的新实例。Initializes a new instance of the InstallException class with serialized data.

InstallException(String, Exception) InstallException(String, Exception) InstallException(String, Exception) InstallException(String, Exception)

初始化 InstallException 类的新实例,并指定要向用户显示的消息,以及对作为该异常原因的内部异常的引用。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() InstallException() InstallException()

初始化 InstallException 类的新实例。Initializes a new instance of the InstallException class.

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

示例

下面的示例演示了InstallException构造函数。The following example demonstrates the InstallException constructor. 它是InstallException类的示例的一部分。It is a part of the example of the InstallException class.

在此示例中, installutil.exe 调用Commit方法。In this example, Installutil.exe calls the Commit method. Commit的代码假定名为的文件FileDoesNotExist.txt在安装程序集之前已存在。The code in Commit presumes that a file named FileDoesNotExist.txt exists before the installation of the assembly can be committed. 如果文件FileDoesNotExist.txt不存在, Commit则引发InstallExceptionIf the file FileDoesNotExist.txt does not exist, Commit raises an InstallException.

备注

此示例演示如何使用InstallException构造函数的重载版本之一。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

InstallException(String) InstallException(String) InstallException(String) InstallException(String)

初始化 InstallException 类的新实例,并指定要显示给用户的消息。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)

参数

message
String String String String

要显示给用户的消息。The message to display to the user.

示例

下面的示例演示了InstallException构造函数。The following example demonstrates the InstallException constructor. 它是InstallException类的示例的一部分。It is a part of the example of the InstallException class.

在此示例中, installutil.exe 调用Uninstall方法。In this example, Installutil.exe calls the Uninstall method. 仅当名为FileDoesNotExist.txt的文件存在时才会发生卸载。Uninstallation will only happen if a file named FileDoesNotExist.txt exists. 否则, 会引发InstallExceptionOtherwise it raises an InstallException.

备注

此示例演示如何使用InstallException构造函数的重载版本之一。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

InstallException(SerializationInfo, StreamingContext) InstallException(SerializationInfo, StreamingContext) InstallException(SerializationInfo, StreamingContext) InstallException(SerializationInfo, StreamingContext)

用序列化数据初始化 InstallException 类的新实例。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)

参数

info
SerializationInfo SerializationInfo SerializationInfo SerializationInfo

包含有关所引发异常的序列化对象数据的 SerializationInfoThe SerializationInfo that holds the serialized object data about the exception being thrown.

context
StreamingContext StreamingContext StreamingContext StreamingContext

StreamingContext,它包含关于源或目标的上下文信息。The StreamingContext that contains contextual information about the source or destination.

InstallException(String, Exception) InstallException(String, Exception) InstallException(String, Exception) InstallException(String, Exception)

初始化 InstallException 类的新实例,并指定要向用户显示的消息,以及对作为该异常原因的内部异常的引用。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)

参数

message
String String String String

要显示给用户的消息。The message to display to the user.

innerException
Exception Exception Exception Exception

导致当前异常的异常。The exception that is the cause of the current exception. 如果 innerException 参数不为 null,则当前异常将在处理内部异常的 catch 块中引发。If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

适用于