InstallException 构造函数 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 InstallException 类的新实例。
重载
| InstallException() | 初始化 InstallException 类的新实例。 | 
| InstallException(String) | 初始化 InstallException 类的新实例,并指定要显示给用户的消息。 | 
| InstallException(SerializationInfo, StreamingContext) | 用序列化数据初始化 InstallException 类的新实例。 | 
| InstallException(String, Exception) | 初始化 InstallException 类的新实例,并指定要向用户显示的消息,以及对作为该异常原因的内部异常的引用。 | 
InstallException()
初始化 InstallException 类的新实例。
public:
 InstallException();public InstallException ();Public Sub New ()示例
下面的示例演示 构造 InstallException 函数。 它是 类示例的 InstallException 一部分。
在此示例中,Installutil.exe 调用 Commit 方法。 中的 Commit 代码假定在可以提交程序集安装之前存在名为 FileDoesNotExist.txt 的文件。 如果文件 FileDoesNotExist.txt 不存在, Commit 将 InstallException引发 。
注意
此示例演示如何使用构造函数的重载版本 InstallException 之一。 有关可能可用的其他示例,请参阅各个重载主题。
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 类的新实例,并指定要显示给用户的消息。
public:
 InstallException(System::String ^ message);public InstallException (string message);new System.Configuration.Install.InstallException : string -> System.Configuration.Install.InstallExceptionPublic Sub New (message As String)参数
- message
- String
要显示给用户的消息。
示例
下面的示例演示 构造 InstallException 函数。 它是 类示例的 InstallException 一部分。
在此示例中,Installutil.exe 调用 Uninstall 方法。 仅当存在名为 FileDoesNotExist.txt 的文件时,才会发生卸载。 否则,它将引发 InstallException。
注意
此示例演示如何使用构造函数的重载版本 InstallException 之一。 有关可能可用的其他示例,请参阅各个重载主题。
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 类的新实例。
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.InstallExceptionProtected Sub New (info As SerializationInfo, context As StreamingContext)参数
- info
- SerializationInfo
包含有关所引发异常的序列化对象数据的 SerializationInfo。
- context
- StreamingContext
StreamingContext,它包含关于源或目标的上下文信息。
适用于
InstallException(String, Exception)
初始化 InstallException 类的新实例,并指定要向用户显示的消息,以及对作为该异常原因的内部异常的引用。
public:
 InstallException(System::String ^ message, Exception ^ innerException);public InstallException (string message, Exception innerException);new System.Configuration.Install.InstallException : string * Exception -> System.Configuration.Install.InstallExceptionPublic Sub New (message As String, innerException As Exception)参数
- message
- String
要显示给用户的消息。
- innerException
- Exception
导致当前异常的异常。 如果 innerException 参数不为 null,则当前异常将在处理内部异常的 catch 块中引发。